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

[Solved] FindControl

1 Answer 97 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hamid va
Top achievements
Rank 1
Hamid va asked on 07 Oct 2009, 09:10 AM
 Hi , 
 In CreatUserWizard . when we want using a asp control  
 using this metod:

string Firstname = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtfirstname")).Text.ToString();
 
 but if in form using a radcontrol got a control casting error  , 
 
 what Can i Do ?
 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Oct 2009, 11:19 AM
Hello Hamid,

When using RadControls, you would have to typecast the control to be accessed to the RadControl as shown in the example below:
aspx:
   <asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
                <WizardSteps> 
                    <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"
                        <ContentTemplate> 
                            <table border="0">                                                             
                                <tr> 
                                    <td align="right"
                                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label></td
                                    <td> 
                                        <telerik:RadTextBox ID="UserName" runat="server"
                                        </telerik:RadTextBox> 
              .... 

c#:
 string username = ((RadTextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName")).Text; 

Thanks
Princy.
Tags
General Discussions
Asked by
Hamid va
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or