Last post Aug 26, 2010 03:38 AM by Qin Dian Tang - MSFT
Aug 19, 2010 07:34 AM|monadotnet|LINK
I have used calender web user control inside my project where i took textbox,button and calender.....but after dragging onto my aspx page....i am unable to access this textbox,calender and button on aspx page...Pls help me to find out the solution.
Aug 19, 2010 10:03 AMfirstname.lastname@example.org|LINK
Child controls contained within a usercontrol are usually private. To access a child control from outside the usercontrol you'll
need to change its visibility to public or internal. In order to change controls visibility just
open up the user control in design mode and select the TextBox you want to access. Then, in the Properties Box, look for the Modifiers
property and change it from private to internal.
You can then access the control with code such as:
userControl1.textBox1.Text = "Welcome User";
Alternatively, you can add a public or internal method to the usercontrol to set the property:
public SetText(string s)
this.textBox1.Text = s;
and call with:
Wish it helps
Aug 20, 2010 12:22 AM|monadotnet|LINK
i have set the method but in the aspx page only 2 options in intellisense are coming that is ReferenceEquals and equals
Aug 23, 2010 10:29 PM|Qin Dian Tang - MSFT|LINK
You can create some property in user control to set or get the controls in it.For example, if you want to change the Text of TextBox on the page which uses the user control. You can create a property in user control to set the Text in user control. Then
on the page you just need to set or change that property to access the TextBox.
Aug 26, 2010 03:26 AM|monadotnet|LINK
i have made property n try to access the text but on aspx page empty string is coming in s.....TextBox1Text is also showing empty string
protected void btnsave_Click(object sender, EventArgs e)
s = calendarusrctrl.TextBox1Text.ToString();
Label3.Text = s;
property in ascx page..
public string TextBox1Text
TextBox1.Text = value;
Aug 26, 2010 03:38 AM|Qin Dian Tang - MSFT|LINK
Please refer the way in this article to create and set property in user control: