ASP.Net User Control Event Bubbling (C#) -
Thank you very much in the past I have done my due diligence and have researched for 2 days, but I think online tutorials I can not wrap my mind around the description of
Status: Lead programmer up and quit the firm's owner know that I have some (novice) to wire functionality between written two custom user control on the side of VB.NET and me intranet app (Written in C # - a small idea to answer professionals - I'm fluent in Visual Studio ... but still learning C #).
Here is a simple description of control, but we hope that we can go in the right direction:
UserControl_1 contains multiple linkbutton when clicked, then in UserControl_2 one should change the value of the SelectParameter selected ObjectDataSource:
& asp: LinkButton ID = "OpenBtn1" runat = "server" text display = "Open Request" / & Gt; & Lt; Asp: LinkButton id = "Closed Btn1" runat = "server" text = "Show closed request" /> UserControl_2 (GridView with DataSource): and asp: ObjectDataSource ID = "ObjectDataSource1" runat = "server" SelectMethod = "GetDataBy_Status" Prkarnam = "adhoc_TblAdptrs.adhoc_TblAdptr" & gt; & Lt; SelectParameters & gt; & Lt; Asp: parameter defaultwall = "all" name = "status" type = "string" /> & Lt; / SelectParameters & gt; & Lt; / ASP: ObjectDataSource & gt; & Lt; Asp: GridView1 id = "GridView1" runat = "server" datasource id = "objectdatasource 1" />
What do I want to do, pass a new default value to SelectParameter of ObjectDataSource in UserControl_2 I'm waiting for personal details from professionals! Your help is highly appreciated!
I will expose property UserControl2, which in turn, set the parameter value
public String Paramaveview {get; Set; } Protected void Objektdetasors 1 Sailicing (object sender, Objektdetasarsscingaeventargs e) {if (Paramvlu. Laganl & gt; 0) {e. Inpatrameters ["status"] = Paramavu; }}
In addition, create a public method in the page that sets the control in the property
Public Zero SetParamValue (string value) {UserControl_2.ParamValue = value; }
Here, in Linkbtn click event, you can only set public properties using the method of the page:
void OpenBtn1_Click (object sender , EventArgs e) {(YourPageClassHere) this.Page). SETParamValue ("Open"); }
This method will get a job, but it will control the pair with linkbuttons for this specific page.
If you want to delete pairing, you can apply an interface with the method
public interface IPAMTARP page {public Zero setperm value (string value)}
Then in your page you will apply it and check the code for the control page
zero OpenBtn1_Click ( Object Sender, EventArgs e) {If this (this.Page is IParameterValuePage) {(IParameterValuePage) this.Page). SETParamValue ("Open"); } And (new exception throw) ("page should apply IParameterValuePage"); }}
Comments
Post a Comment