how to store the value in textbox using delegates if we have
two user control. the value will be called from one user
control to another user control. Loading and unloading will
be done through delegates.
Answer / thomasjoseph valiyamattam
first user control
---------------------------
Create an event in the first user control
public delegate void ctrlchanges(object sender,
DelegateArgs e);
public event ctrlchanges ctrlChange;
in the first usercontrols button click
1) set values to DelegateArgs properties id and name
2) then Invoke the delegates
if (ctrlChange != null)
{
ctrlChange(this, args);
}
/*
DelegateArgs is a class having properties to set and get
id and name.
here id and name are set from first user ctrol and get at
second user control
this is to reflect changes in the first control to second
control
*/
second user control
--------------------------
in the seccond user control
write a function to get the DelegateArgs members and set
to textBoxes
public void ChangeDetails(object sender, DelegateArgs
args)
{
txt1.Text = args.Id.ToString();
txt2.Text = args.Name;
}
Aspx.cs
---------------
write the code in the page load
to access function of second user control from first
user control
protected void Page_Load(object sender, EventArgs e)
{
((DelegateCtrl_1)DelegateCtrl_1_1).ctrlChange += new
DelegateCtrl_1.ctrlchanges(((DelegateCtrl_2)
DelegateCtrl_2_1).ChangeDetails);
}
/*
DelegateCtrl_1 is the first user control and its id is
DelegateCtrl_1_1
<uc1:DelegateCtrl_1 ID="DelegateCtrl_1_1"
runat="server" />
*/
| Is This Answer Correct ? | 1 Yes | 3 No |
What is reflection c#?
Does the system.exception class have any cool features?
What is join in c#?
What is the difference between a method and a property?
what is boxing and unboxing?can we initialize unboxing directly?
Can abstract class be instantiated c#?
What is the resgen.exe tool used for?
Can you prevent your class from being inherited and becoming a base class for some other classes?
What?s the implicit name of the parameter that gets passed into the class? set method?
What is a method signature?
Explain about Protected and protected internal, ?internal? access-specifier?
What is JIT (just in time)? how it works?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)