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

radtextbox findcontrol

2 Answers 117 Views
Input
This is a migrated thread and some comments may be shown as answers.
Eric Schuler
Top achievements
Rank 1
Eric Schuler asked on 27 Jul 2010, 10:33 PM
I am using radtextbox on a form with no radgrid.  I am trying to find the control using the findcontrol method but I have not been successful.   The code is very simple:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 
<telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server"
 Skin="WebBlue" />  
 
<div  class="tablediv">
<div class="rowdiv">
 
<div  class="celldivleft">First Name:</div>
<div  class="celldivright">
    <asp:TextBox ID="FirstNameBox" runat="server"></asp:TextBox></div>
</div>   
     
<div class="rowdiv">
 
<div  class="celldivleft">Last Name:</div>
<div  class="celldivright">
    <asp:TextBox ID="LastNameBox" runat="server"></asp:TextBox></div>
 </div>  
  
<div class="rowdiv">
<div  class="celldivleft">Last Name:</div>
<div  class="celldivright"><telerik:RadTextBox ID="RadTextBox1" runat="server">
    </telerik:RadTextBox></div>
     
</div>
     
       
    <div class="rowdiv">
     
        <div  class="celldivleft">
         
        </div>
         
        <div  class="celldivright">
         
            <asp:Button ID="SubmitButton" runat="server" Text="Submit"
        onclick="SubmitButton_Click" />
        </div>
    </div>
     
</div>
  
 
</asp:Content>

And the code behind to find the control:

protected void Page_InitComplete(object sender, EventArgs e)
    {
          RadTextBox rtb = (this.Page.FindControl("RadTextBox1") as RadTextBox);
 
    }

No matter what I do rtp comes up null...cannot find control.   I am new to Telerik so it is probably something stupid but can you help?

Thanks,

Eric

2 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 30 Jul 2010, 02:28 PM
Hi Eric,

Why not reference the controls by its ID directly instead of triggering a search for it? You can just write:

RadTextBox1.Text = "some value";
for example.

Hope it helps.

Regards,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Eric Schuler
Top achievements
Rank 1
answered on 05 Aug 2010, 05:24 PM


Thanks for the suggestion.  That definitely works :-)   I am relatively new to the controls...but if I look at all of the examples for this control they all seem to involve using that findcontrol method in one form or another.   Perhaps that method is just intended for more complex uses, such as when a radgrid is used in conjunction with....   In any event thanks very much for the response.   Someone in support was kind enough to supply me with a test program that I will check out as well.   Eric.
Tags
Input
Asked by
Eric Schuler
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Eric Schuler
Top achievements
Rank 1
Share this question
or