This is a migrated thread and some comments may be shown as answers.

RadToolbar textbox value pass to usercontrol

1 Answer 100 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Nareshkumar
Top achievements
Rank 1
Nareshkumar asked on 27 Jan 2014, 04:33 PM
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

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Jan 2014, 04:01 AM
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.
Tags
ToolBar
Asked by
Nareshkumar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or