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

    hi,
    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?

    Thanks,
    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.

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

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

    ASPX C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        Control mynewcontrol = new Control();
        //loading user control to the page
        mynewcontrol = LoadControl("WebUserControl.ascx");
        this.Controls.Add(mynewcontrol);
        //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.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top