Get the user input value from textbox which is in PanelBar

6 posts, 1 answers
  1. Ana
    Ana avatar
    12 posts
    Member since:
    Apr 2014

    Posted 26 Jun 2014 Link to this post

    Hi,

    I have a panelbar and within that I have a textbox. When user entered a value into that textbox, I want to get that value and save when user click on submit. Rightnow I have this issue. Soon after user click on submit the user input value is wiped off from text box. When I debugged the debugger is also not reading that value. It is just displaying as an empty.

    How can I read that value and save it?

    Thank you.
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Jun 2014 in reply to Ana Link to this post

    Hi Ana,

    Please have a look into the sample code snippet to access the RadTextBox values which is inside the ContentTemplate and ItemTemplate of RadPanelBar.

    ASPX:
    <telerik:RadPanelBar ID="rpanelbarTextBox" runat="server">
        <Items>
            <telerik:RadPanelItem Text="ContentTemplateTextBox">
                <ContentTemplate>
                    <telerik:RadTextBox ID="rtxtContentTemplateValue" runat="server" Label="Content Template">
                    </telerik:RadTextBox>
                </ContentTemplate>
            </telerik:RadPanelItem>
            <telerik:RadPanelItem Text="ItemTemplateTextBox">
                <ItemTemplate>
                    <telerik:RadTextBox ID="rtxtItemTemplateValue" runat="server" Label="Item Template">
                    </telerik:RadTextBox>
                </ItemTemplate>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>
    <telerik:RadButton ID="rbtnSubmit" runat="server" Text="Submit" OnClick="rbtnSubmit_Click">
    </telerik:RadButton>

    C#:
    protected void rbtnSubmit_Click(object sender, EventArgs e)
    {
        //textbox inside the contenttemplate
        string contentTemplateTextValue = rtxtContentTemplateValue.Text;
        //accessing the textbox inside the itemtemplate
        RadTextBox itemTemplateTextBox = rpanelbarTextBox.FindItemByText("ItemTemplateTextBox").FindControl("rtxtItemTemplateValue") as RadTextBox;
        string itemTemplateTextValue = itemTemplateTextBox.Text;
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ana
    Ana avatar
    12 posts
    Member since:
    Apr 2014

    Posted 27 Jun 2014 in reply to Shinu Link to this post

    Hi Shinu,

    I tried and still not able to get the user input after entered into text box. 

    Please find below attached sample code.  My requirement here is when user entered a value into rtxtOrderNum, i want to save it to some string variable and pass to data table to save and he click on Submit button. 

    ASPX Code:

    <telerik:RadPanelBar Runat="server" ID="rpanelbarTextBox"><br>    <items><br>        <telerik:RadPanelItem runat="server" Text="Customer Data"><br>            <ContentTemplate><br>                <telerik:RadTextBox ID="rtxtOrderNum" Runat="server"><br>                </telerik:RadTextBox><br>                <asp:Button ID="rbtnSubmit" runat="server" OnClick="rbtnSubmit_Click" Text="Submit" /><br>            </ContentTemplate><br>        </telerik:RadPanelItem><br>        <telerik:RadPanelItem  Text="Orders Data"><br>            <ContentTemplate><br>                <telerik:RadTextBox ID="rtxtOrderID" Runat="server"><br>                </telerik:RadTextBox><br>            </ContentTemplate><br>        </telerik:RadPanelItem><br>    </items><br></telerik:RadPanelBar>

    C# Code:

       protected void rbtnSubmit_Click(object sender, EventArgs e)<br>        {<br>            //??? <br><br>        }<br>    }

  5. Ana
    Ana avatar
    12 posts
    Member since:
    Apr 2014

    Posted 28 Jun 2014 Link to this post

    Shinu,

    Also I want to mention one point to be more clear on the issue.

    During page load, the text box value is assigned with Databind.

    After this page load user let to change the text box Text.  When user modifies this text box value the debugger still shows the original data bound value.  It is not considering the newly edited value by user.   That is the problem I am facing.

    For example:  the text box value after page load and data bind is say..... Telerik
    Now the user modified the this value to Telerik Controls

    My requirement is to capture the modified value.  But, my debugger is still showing the text box  Text as Telerik but not Telerik Controls.

    One more thing:
    Unlike in your example, my ASPX code has both text box control and Submit button with Item Template of Rad Panel bar. I do not have any content template.

    Hope I am clear. 
  6. Ana
    Ana avatar
    12 posts
    Member since:
    Apr 2014

    Posted 28 Jun 2014 Link to this post

    Hi Shinu,

    I have been searching for the solution and found a link which exactly describes my issue. The code snippet is completely provided in the below link.  Please check and I am sure you will reproduce the issue.    

    http://www.telerik.com/forums/get-content-of-a-textbox-within-an-item-termplate#-4NEqboUzUemvZeGv9mChw

    Thank you.
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Jun 2014 in reply to Ana Link to this post

    Hi Ana,

    From your code I have noticed that you are assigning the TextBox value to Page_Load event. Whenever a postback is happening the Page_Load event will fire, so in your case when the button click is happening first the Page_Load will fire and its assigning "Telerik" value to the RadTextBox and your updated value is not persisting. Please do the following modification in your Page_Load event and then try to access the updated value on the button click.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RadTextBox txtbox = (RadTextBox)(RadPanelBar1.FindItemByValue("templateHolder").FindControl("RadTextBoxEmail"));
            txtbox.Text = "Telerik";
        }
    }

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017