Saturday, March 24, 2012

Object reference not set to an instance of an object

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 btnSubmit

protected override void OnInit(EventArgs e)
{
btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
}
void btnSubmit_Click(Object sender, EventArgs e)
{
String domain, str_path, objName;
//code to create obj
if (IsValid) {
...
try
{
DirectoryEntry myDir = new DirectoryEntry(str_path);
...
}
catch (Exception Exception1)
{
System.Runtime.InteropServices.COMException COMEx =
(System.Runtime.InteropServices.COMException)Excep tion1;
//ConsoleWriteline(COMEx.ErrorCode);
}

//code to add UPN

//code to create LDAP files
}
}
--
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.IPo stBackEventHandler.RaisePo
stBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

--The error is in btnOUCreate_Cli*ck event. Need to see that code
Sorry, please see my other post ( Subject: ..... - newpost) TIA

"BillGatesFan" <klj_mcsd@.hotmail.com> wrote in message
news:1115695125.473044.62560@.f14g2000cwb.googlegro ups.com...
The error is in btnOUCreate_Cli*ck event. Need to see that code
Sorry, please see my other post ( Subject: ..... - newpost) TIA

"BillGatesFan" <klj_mcsd@.hotmail.com> wrote in message
news:1115695125.473044.62560@.f14g2000cwb.googlegro ups.com...
The error is in btnOUCreate_Cli*ck event. Need to see that code
What are u trying to do exactly?

"dl" wrote:

> 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 btnSubmit
> protected override void OnInit(EventArgs e)
> {
> btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
> }
> void btnSubmit_Click(Object sender, EventArgs e)
> {
> String domain, str_path, objName;
> //code to create obj
> if (IsValid) {
> ...
> try
> {
> DirectoryEntry myDir = new DirectoryEntry(str_path);
> ...
> }
> catch (Exception Exception1)
> {
> System.Runtime.InteropServices.COMException COMEx =
> (System.Runtime.InteropServices.COMException)Excep tion1;
> //ConsoleWriteline(COMEx.ErrorCode);
> }
> //code to add UPN
> //code to create LDAP files
> }
> }
> --
> 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.IPo stBackEventHandler.RaisePo
> stBackEvent(String eventArgument) +57
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> --
>
>

0 comments:

Post a Comment