Find RadInput control in form View

3 posts, 1 answers
  1. sayitfast
    sayitfast avatar
    57 posts
    Member since:
    Oct 2006

    Posted 15 Sep 2008 Link to this post

    I'm trying to set a radTextBox's text to the value of cookie... but I keep getting an error that Object is not set to reference of an object. 

    Little help!

    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Collections;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Web.UI.HtmlControls;  
    using System.IO;  
    using System.Collections.Specialized;  
    using System.Drawing;  
    using Telerik.WebControls;  
     
     
    public partial class UserArticleDetails : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
              
        }  
        protected void FormView1_PreRender1(object sender, EventArgs e)  
        {  
            if (this.FormView1.CurrentMode == FormViewMode.Insert)  
            {  
                //This works  
                TextBox txtName1 = this.FormView1.FindControl("txtName") as TextBox;  
                txtName1.Text = "test";  
     
                //This does not work  
                TextBox radName = this.FormView1.FindControl("radTextBox1") as TextBox;  
                radName.Text = "hello";  
            }  
        } 
  2. Answer
    Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 16 Sep 2008 Link to this post

    Hello Rhett,

    Maybe you mean:
    //This works   
    TextBox txtName1 = this.FormView1.FindControl("txtName"as TextBox; 
    txtName1.Text = "test"
     
    //This does not work   
    RadTextBox radName = this.FormView1.FindControl("radTextBox1"as RadTextBox; 
    radName.Text = "hello";   

    Regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. sayitfast
    sayitfast avatar
    57 posts
    Member since:
    Oct 2006

    Posted 16 Sep 2008 Link to this post

    Doh!!!  Thanks....

    Rhett
Back to Top