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

Get the user input value from textbox which is in PanelBar

6 Answers 156 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Ana
Top achievements
Rank 1
Ana asked on 26 Jun 2014, 10:22 PM
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.

6 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 27 Jun 2014, 05:32 AM
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.
0
Ana
Top achievements
Rank 1
answered on 27 Jun 2014, 03:23 PM
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>    }

0
Ana
Top achievements
Rank 1
answered on 28 Jun 2014, 08:24 PM
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. 
0
Ana
Top achievements
Rank 1
answered on 29 Jun 2014, 12:36 AM
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.
0
Shinu
Top achievements
Rank 1
answered on 30 Jun 2014, 03:01 AM
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.
0
Edgar
Top achievements
Rank 1
answered on 12 Dec 2019, 05:34 AM
Excelente ayuda mi estimado.
Tags
PanelBar
Asked by
Ana
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Ana
Top achievements
Rank 1
Edgar
Top achievements
Rank 1
Share this question
or