RadToolbar textbox value pass to usercontrol

2 posts, 0 answers
  1. Nareshkumar
    Nareshkumar avatar
    5 posts
    Member since:
    Oct 2013

    Posted 27 Jan 2014 Link to this post

    i am using radtoolbar, in which i am having textbox. by default i am setting some value to the text box. i can change textbox value if i changed value of the textbox, the value as to pass to usercontrol. how should i pass value from page to usercontrol?

    Nareshkumar K S
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Jan 2014 in reply to Nareshkumar Link to this post

    Hi Nareshkumar,

    Please have a look into the sample code snippet to achieve your scenario.

    <telerik:RadToolBar ID="RadToolBar1" runat="server">
            <telerik:RadToolBarButton runat="server" Value="Button1">
                    <telerik:RadTextBox ID="RadTextBox1" runat="server" Text="Demo">
    <telerik:RadButton ID="RadButton1" runat="server" Text="PassValue" OnClick="RadButton1_Click">

    <telerik:RadTextBox ID="RadTextBox2" runat="server">

    ASPX C#:
    protected void RadButton1_Click(object sender, EventArgs e)
        Control mynewcontrol = new Control();
        //loading user control to the page
        mynewcontrol = LoadControl("WebUserControl.ascx");
        //accessing textbox inside usercontrol
        RadTextBox UserTextBox = (RadTextBox)mynewcontrol.FindControl("RadTextBox2");
        //accessing textbox inside toolbar
        RadTextBox ToolbarText = (RadTextBox)RadToolBar1.FindItemByValue("Button1").FindControl("RadTextBox1");
        //assigning value to the text inside usercontrol
        UserTextBox.Text = ToolbarText.Text;

    Hope this will helps you.
Back to Top