To access a control placed in a web user control which is loaded during page load in button click event


How can I access a control in a web user control in a button click event , the user control is loaded in page load.

Thanks & Regards,
Abhiram Reddy Mekha.
0
AbhiramReddyMekha
11/18/2008 4:22:55 AM
📁 asp.net.web-forms
📃 93655 articles.
⭐ 6 followers.

💬 2 Replies
👁️‍🗨️ 1484 Views


Try checking this...
http://microsoft.apress.com/asptodayarchive/73869/event-handling-between-custom-user-controls-that-are-loaded-at-run-time
http://aspalliance.com/565_Dynamic_Loading_of_ASPNET_User_Controls
http://www.beansoftware.com/ASP.NET-Tutorials/Controls-Run-Time.aspx
http://stackoverflow.com/questions/92792/user-control-created-dynamically-not-able-to-handle-events-on-postback
http://www.codersource.net/asp_net_user_controls_azam.aspx
0
dreamz
11/18/2008 5:36:37 AM

Hi,
Based on your description, you want to access a control nested in a user control on the host page.
A user control is a composite control and all its child controls and script serve as a unit. So, we can't directly access the nested controls in it.
However, we can expose some properties for our user controls and make them public. We can get some information of the nested controls through these properties.
For instance: assume a TextBox control is nested in a user control we can define a property like this to get the Text property of the TextBox control.

 

 public string getText
    {
        get
        {
            return TextBox1.Text;
        }
        set
        {
            TextBox1.Text = value;
        }
    }    
 

Have a nice day!
 

Forward Sun
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Forward
11/23/2008 12:55:37 PM
Reply: