Fail code using RadTextbox

3 posts, 0 answers
  1. tuonglam
    tuonglam avatar
    5 posts
    Member since:
    Mar 2011

    Posted 13 Mar 2011 Link to this post

    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. tuonglam
    tuonglam avatar
    5 posts
    Member since:
    Mar 2011

    Posted 15 Mar 2011 Link to this post

    who can help me please? :((
  3. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 16 Mar 2011 Link to this post

    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!
Back to Top