Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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.



how to store the value in textbox using delegates if we have two user control. the value will be ca..

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

Post New Answer

More C Sharp Interview Questions

What are predicates in c#?

0 Answers  


Explain the difference between // comments, /* */ comments and /// comments?

0 Answers  


How do you declare an arraylist?

0 Answers  


Explain about c# language.

0 Answers  


Can abstract class be sealed in c#?

0 Answers  


What are the different types of assemblies available and their purpose?

0 Answers  


What are custom exceptions in C#?

0 Answers   Arigo Infotech,


Explain attributes in c#?

0 Answers  


What's new in c#?

0 Answers  


My switch statement works differently! Why?

0 Answers  


How can we main a Class as base class,i.e not inherited further?{please Dont tell using Sealed class,any other way}

6 Answers   ACB Group, IBM, Tech Mahindra,


What?s the difference between the System.Array.CopyTo() and System.Array.Clone()?

6 Answers   Wipro,


Categories