Access textbox value inside RadMultiPage

5 posts, 1 answers
  1. Terri-Lynn
    Terri-Lynn avatar
    45 posts
    Member since:
    Dec 2010

    Posted 19 Aug 2013 Link to this post

    Hi all:

    I've read quite a few similar threads, but none specifically like mine.  I have a page with a nested FormView > EditItemTemplate > RadTabStrip> RadMultiPageView > RadPageView.  I need to find the value of a textbox on one of the RadPageView, and am having trouble.  I'm using VB.NET, and need to get the value of this textbox in my CodeBehind file.  Any help out there, or is more detail required?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Aug 2013 Link to this post

    Hi Terri-Lynn,

    Please try the following code snippet that I have tried to access RadTextBox value from code behind.

    ASPX:
    <asp:FormView ID="FormView1" runat="server" EnableViewState="true" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                Text="Edit">
            </asp:LinkButton>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadTabStrip runat="server" ID="RadTabStrip1" MultiPageID="RadMultiPage1"
                SelectedIndex="0" Skin="Silk">
                <Tabs>
                    <telerik:RadTab Text="Tab1" Width="700px">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
            <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0">
                <telerik:RadPageView runat="server" ID="RadPageView1">
                    <telerik:RadTextBox ID="RadTextBox1" runat="server" Text="temp"
                        OnLoad="RadTextBox1_Load">
                    </telerik:RadTextBox>
                </telerik:RadPageView>
            </telerik:RadMultiPage>
        </EditItemTemplate>
    </asp:FormView>

    VB:
    Protected Sub RadTextBox1_Load(sender As Object, e As EventArgs)
        Dim ctrl2 As RadTextBox = DirectCast(sender, RadTextBox)
        Dim value = ctrl2.Text
        Response.Write("<script>alert('" + value + "');</script>")
    End Sub

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Terri-Lynn
    Terri-Lynn avatar
    45 posts
    Member since:
    Dec 2010

    Posted 20 Aug 2013 Link to this post

    Thanks Princy!  Yes, that works, but I need to simply "find" the control after a click of a button.  The DirectCast won't work in this case since the sender isn't the control itself.  Make sense?  Any other help would be greatly appreciated.
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Aug 2013 Link to this post

    Hi Terri-Lynn,

    Please have a look at the following code snippet.

    ASPX:
    <asp:FormView ID="FormView1" runat="server" EnableViewState="true" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                Text="Edit">
            </asp:LinkButton>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadTabStrip runat="server" ID="RadTabStrip1" MultiPageID="RadMultiPage1"
                SelectedIndex="0" Skin="Silk">
                <Tabs>
                    <telerik:RadTab Text="Tab1" Width="700px">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
            <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0">
                <telerik:RadPageView runat="server" ID="RadPageView1">
                    <telerik:RadTextBox ID="RadTextBox1" runat="server" Text="temp" OnLoad="RadTextBox1_Load">
                    </telerik:RadTextBox>
                </telerik:RadPageView>
            </telerik:RadMultiPage>
            <telerik:RadButton ID="RadButton1" runat="server" Text="Click" OnClick="RadButton1_Click">
            </telerik:RadButton>
        </EditItemTemplate>
    </asp:FormView>

    VB:
    Public Shared txtvalue As RadTextBox
    Protected Sub RadTextBox1_Load(sender As Object, e As EventArgs)
        txtvalue = DirectCast(sender, RadTextBox)
    End Sub
    Protected Sub RadButton1_Click(sender As Object, e As EventArgs)
        Dim value = txtvalue.Text
        Response.Write("<script>alert('" + value + "');</script>")
     
    End Sub

    Let me know if it doesn't help you.
    Thanks,
    Princy.
  6. Terri-Lynn
    Terri-Lynn avatar
    45 posts
    Member since:
    Dec 2010

    Posted 21 Aug 2013 Link to this post

    That works beautifully!  Thanks again for taking the time to help with this.  Greatly appreciated.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017