Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Tabstrip > How to get the value of control in different ascx
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Answered How to get the value of control in different ascx

Feed from this thread
  • RS avatar

    Posted on Feb 15, 2011 (permalink)

    Hello,

    I'm new to telerik and using ASP.NET3.5 / C#.
    I'm trying to have a TabStrip using it as a Wizard just like the Demo on the telerik site. The only difference is I want to have a Preview ascx as one of the TabStrip instead of having it displayed beside the TabStrip.

    Is it possible to get/view the value of controls in different ascx?
    For example, using Demo for TabStrip/Wizard, is it possible to get the value of 'First Name' which is in the 'PersonalCS.ascx from 'EducationCS.ascx.cs'?

    Thank you in advance,

    RS

  • RS avatar

    Posted on Feb 15, 2011 (permalink)

    I got it using usercontrol!

    But now different question came up.
    Using Demo 'TabStrip/Wizard' as a example, I could get the value of 'First Name' text box in 'PersonalCS.ascx' from 'EducationCS.ascx.cs', but how can I get it from 'DefaultCS.aspx.cs'?
    If I use the same method, it gives me error saying 'Object reference not set to an instance of an object' for usercontrol.

    I appreciate any help!
    Thank you in advance.

    RS

  • Answer Shinu MVP avatar

    Posted on Feb 16, 2011 (permalink)

    Hello,

    You can access the UserControl using Page.FindControl() method. Here is a sample code for accessing the UserControl on the ButtonClick event, which is in the Default.aspx page
    C#:.
    protected void Button1_Click(object sender, EventArgs e)
     {
         UserControl uc = (UserControl)Page.FindControl(ucID);//here ucID is the ID of the user control
         TextBox firstName = uc.FindControl("firstNameTextBox") as TextBox;
     }

    Thanks,
    Shinu.

  • RS avatar

    Posted on Feb 16, 2011 (permalink)

    Thank you Shinu!
    I really appreciate your quick reply to my question.
    I tried it but still gives me the same kind of error... This time the error raises at "TextBox firstName = uc.FindControl("firstNameTextBox") as TextBox;"
    I set the if statement to check  whether uc(UserControl) is null or not and it returned uc as null....


    Any suggestion or help will be appreciated.
    Thank you for your time.

    RS

  • RS avatar

    Posted on Feb 16, 2011 (permalink)

    Yay! I got it work!
    I defined usercontrol like following.

     

    UserControl uc = (UserControl)RadMultiPageID.FindControl("ucID");

    Thanks!

    RS

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Tabstrip > How to get the value of control in different ascx