Object reference not set to an instance of an object - newpost

G

Guest

Hi
Any idea what's happening, please?! TIA, details.....

I have a formA.aspx page and a corresponding class file formA.cs compiled
into a library. User is to fill out some information and click a submit
button to trigger a click event. Here is what I have in formA.cs

{
public Button btnOUCreate;
public Label Label1;
public TextBox txtACNo, txtCompanyName;

public ouCreate() {
}

void InitializeComponent()
{
btnOUCreate.Click += new
System.EventHandler(this.btnOUCreate_Click);
}
protected override void OnInit(EventArgs e)
{
this.InitializeComponent();
base.OnInit(e);
//throw new Exception("The method or operation is not
implemented.");
}
void Page_Load(object sender, EventArgs e)
{
//IPrincipal myPrincipal = this.User;
Label1.Text = HttpContext.Current.User.Identity.Name;

}
void btnOUCreate_Click(Object sender, EventArgs e)
{
String domain, str_path, newOUName;
//code to create OU
if (IsValid) {
newOUName = txtACNo.Text;
domain =
System.Configuration.ConfigurationSettings.AppSettings["DN"];
str_path = "LDAP://" + domain;
try
{
DirectoryEntry myDir = new DirectoryEntry(str_path);
DirectoryEntry newOU = myDir.Children.Add(newOUName, "OU");
}
catch (Exception Exception1)
{
System.Runtime.InteropServices.COMException COMEx =
(System.Runtime.InteropServices.COMException)Exception1;
//ConsoleWriteline(COMEx.ErrorCode);
}

//code to add UPN

}
}
}

------
Here is the Stack trace
[NullReferenceException: Object reference not set to an instance of an
object.]
NETDS.ouCreate.btnOUCreate_Click(Object sender, EventArgs e) +38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292


--
 
G

Guest

I don't have VS yet ?! will VWD2005 express do it? any other ways to do it?

Curt_C said:
use the VS debugger and step through it....

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


Hi
Any idea what's happening, please?! TIA, details.....

I have a formA.aspx page and a corresponding class file formA.cs compiled
into a library. User is to fill out some information and click a submit
button to trigger a click event. Here is what I have in formA.cs

{
public Button btnOUCreate;
public Label Label1;
public TextBox txtACNo, txtCompanyName;

public ouCreate() {
}

void InitializeComponent()
{
btnOUCreate.Click += new
System.EventHandler(this.btnOUCreate_Click);
}
protected override void OnInit(EventArgs e)
{
this.InitializeComponent();
base.OnInit(e);
//throw new Exception("The method or operation is not
implemented.");
}
void Page_Load(object sender, EventArgs e)
{
//IPrincipal myPrincipal = this.User;
Label1.Text = HttpContext.Current.User.Identity.Name;

}
void btnOUCreate_Click(Object sender, EventArgs e)
{
String domain, str_path, newOUName;
//code to create OU
if (IsValid) {
newOUName = txtACNo.Text;
domain =
System.Configuration.ConfigurationSettings.AppSettings["DN"];
str_path = "LDAP://" + domain;
try
{
DirectoryEntry myDir = new DirectoryEntry(str_path);
DirectoryEntry newOU = myDir.Children.Add(newOUName, "OU");
}
catch (Exception Exception1)
{
System.Runtime.InteropServices.COMException COMEx =

(System.Runtime.InteropServices.COMException)Exception1;
//ConsoleWriteline(COMEx.ErrorCode);
}

//code to add UPN

}
}
}

------
Here is the Stack trace
[NullReferenceException: Object reference not set to an instance of an
object.]
NETDS.ouCreate.btnOUCreate_Click(Object sender, EventArgs e) +38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
 
C

Curt_C [MVP]

well, start taking out and putting back in some of the code till you limit
it down

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


I don't have VS yet ?! will VWD2005 express do it? any other ways to do
it?

Curt_C said:
use the VS debugger and step through it....

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


Hi
Any idea what's happening, please?! TIA, details.....

I have a formA.aspx page and a corresponding class file formA.cs compiled
into a library. User is to fill out some information and click a
submit
button to trigger a click event. Here is what I have in formA.cs

{
public Button btnOUCreate;
public Label Label1;
public TextBox txtACNo, txtCompanyName;

public ouCreate() {
}

void InitializeComponent()
{
btnOUCreate.Click += new
System.EventHandler(this.btnOUCreate_Click);
}
protected override void OnInit(EventArgs e)
{
this.InitializeComponent();
base.OnInit(e);
//throw new Exception("The method or operation is not
implemented.");
}
void Page_Load(object sender, EventArgs e)
{
//IPrincipal myPrincipal = this.User;
Label1.Text = HttpContext.Current.User.Identity.Name;

}
void btnOUCreate_Click(Object sender, EventArgs e)
{
String domain, str_path, newOUName;
//code to create OU
if (IsValid) {
newOUName = txtACNo.Text;
domain =
System.Configuration.ConfigurationSettings.AppSettings["DN"];
str_path = "LDAP://" + domain;
try
{
DirectoryEntry myDir = new DirectoryEntry(str_path);
DirectoryEntry newOU = myDir.Children.Add(newOUName, "OU");
}
catch (Exception Exception1)
{
System.Runtime.InteropServices.COMException COMEx =

(System.Runtime.InteropServices.COMException)Exception1;
//ConsoleWriteline(COMEx.ErrorCode);
}

//code to add UPN

}
}
}

------
Here is the Stack trace
[NullReferenceException: Object reference not set to an instance of an
object.]
NETDS.ouCreate.btnOUCreate_Click(Object sender, EventArgs e) +38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
 
G

Guest

Sorry, problem fixed, -- Wrong control type (HTML controls are used rather
than the Web controls).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top