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

Fail code using RadTextbox

2 Answers 74 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
tuonglam
Top achievements
Rank 1
tuonglam asked on 13 Mar 2011, 07:43 AM
I have the code of my friend using ASP Textbox:

string customerName = (MultiView1.Views[3].FindControl("txtCustomerName") as TextBox).Text;
int age = int.Parse((MultiView1.Views[3].FindControl("txtAge") as TextBox).Text);

so,i replaced ASP Textbox with Rad Textbox but when i debug my code is fail.If i want to using RadTextbox how can i do?

2 Answers, 1 is accepted

Sort by
0
tuonglam
Top achievements
Rank 1
answered on 15 Mar 2011, 11:33 AM
who can help me please? :((
0
Marin
Telerik team
answered on 16 Mar 2011, 07:32 PM
Hello,

Can you provide some more details on the kind of error that you get.
For the above code to work you should have two RadTextBoxes defined in the relevant view of the MultiView control with the respective IDs: txtCustomerName, txtAge (so that they can be found in the code behind). After that you cast them to RadTextBox control.

<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
          ...
          <asp:View ID="View1" runat="server">
           <telerik:RadTextBox ID="txtCustomerName" runat="server"></telerik:RadTextBox>
           <telerik:RadTextBox ID="txtAge" runat="server"></telerik:RadTextBox>
          </asp:View>
        </asp:MultiView>

string customerName = (MultiView1.Views[3].FindControl("txtCustomerName") as RadTextBox).Text;
int age = int.Parse((MultiView1.Views[3].FindControl("txtAge") as RadTextBox).Text);

Also you should make sure that the corresponding view is selected and visible so that the textboxes can be found.


Regards,
Marin
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Ajax
Asked by
tuonglam
Top achievements
Rank 1
Answers by
tuonglam
Top achievements
Rank 1
Marin
Telerik team
Share this question
or