J
jlucas
Hello,
I am new to .Net and I need some help getting access to the controls in my
aspx code. It seems my cs class can not get a good reference to the
controls declared in my aspx file. Here are some code snippets that I have.
CreateUser.aspx
<%@ Page Inherits="CreateUser" Language="C#" Debug="true" %>
.....
<td width=80> <asp:TextBox id="First_Name" type="text" size="15"
runat="server"/></td>
CreateUser.cs
public class CreateUserage
{
protected System.Web.UI.WebControls.TextBox fName;
.......
fName = (TextBox)this.Page.FindControl("First_Name");
//
Console.WriteLine ("Enter the SaveUser Method! " +
fName.Text); //Exception thrown here.
So I have the cs class inherit from Page and then the aspx inherits the
CreateUser class. I have also made the reference in the CreateUser to
TextBox protected (and I have tried public), but I always get this error
"System.NullReferenceException: Object reference not set to an instance of
an object." which goes back to my TextBox control I am trying to use.
I have tried this as Page.FindControl("form1").findControl("First_Name")
and still get the same result.
Thanks for the help,
jlucas
I am new to .Net and I need some help getting access to the controls in my
aspx code. It seems my cs class can not get a good reference to the
controls declared in my aspx file. Here are some code snippets that I have.
CreateUser.aspx
<%@ Page Inherits="CreateUser" Language="C#" Debug="true" %>
.....
<td width=80> <asp:TextBox id="First_Name" type="text" size="15"
runat="server"/></td>
CreateUser.cs
public class CreateUserage
{
protected System.Web.UI.WebControls.TextBox fName;
.......
fName = (TextBox)this.Page.FindControl("First_Name");
//
Console.WriteLine ("Enter the SaveUser Method! " +
fName.Text); //Exception thrown here.
So I have the cs class inherit from Page and then the aspx inherits the
CreateUser class. I have also made the reference in the CreateUser to
TextBox protected (and I have tried public), but I always get this error
"System.NullReferenceException: Object reference not set to an instance of
an object." which goes back to my TextBox control I am trying to use.
I have tried this as Page.FindControl("form1").findControl("First_Name")
and still get the same result.
Thanks for the help,
jlucas