I have two user control's . In the first user control( Class ) i have one textbox
.
Now in my second user control ( Test ), i want to get the value of that textbox
.
in my page, when user enter a value in texbox
of the first usercontrol
, how can i get this in the hidden field of the second usercontrol
How can I do this??
I have these properties in my usercontrols
Class User Control
public string Class_ClientId
{
get { return txtClass.ClientID; }
}
public string Class_Text
{
get { return Class; }
set
{
if (value != Class)
{
Class = value;
txtClass.Text = Class;
}
}
}
Test user control
public string KMAT_Text
{
get { return KMATName; }
set
{
if (value != KMATName)
{
KMATName = value;
txtKmat.Text = KMATName;
}
}
}
public string Class
{
get { return _hdnClass; }
set
{
if (value!= _hdnClass)
{
_hdnClass = value;
hdnClass.Value = _hdnClass;
}
}
}
There are a variety of ways to do this. The easiest to implement would be to define a change event on the first user control:
public event EventHandler SomethingChanged;
protected void OnSomethingChanged(EventArgs e)
{
if (SomethingChanged != null)
SomethingChanged(this, e);
}
public string Class_Text
{
get { return Class; }
set
{
if (value != Class)
{
Class = value;
txtClass.Text = Class;
this.OnSomethingChanged(EventArgs.Empty);
}
}
}
Have the page listen for it, and have the page pass the value to the second user control.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.