Saturday, March 24, 2012

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

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.AppSett ings["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)Excep tion1;
//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.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

--use the VS debugger and step through it...

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

<dl> wrote in message news:OCp9zDRVFHA.1508@.tk2msftngp13.phx.gbl...
> 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.AppSett ings["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)Excep tion1;
> //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.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
>
> --
I don't have VS yet ?! will VWD2005 express do it? any other ways to do it?

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:OjiLhFRVFHA.928@.TK2MSFTNGP15.phx.gbl...
> use the VS debugger and step through it...
> --
> Curt Christianson
> Site & Scripts: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
> <dl> wrote in message news:OCp9zDRVFHA.1508@.tk2msftngp13.phx.gbl...
> > 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.AppSett ings["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)Excep tion1;
> > //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.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
> > --
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

<dl> wrote in message news:e7Kc8IRVFHA.3532@.TK2MSFTNGP09.phx.gbl...
>I don't have VS yet ?! will VWD2005 express do it? any other ways to do
>it?
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:OjiLhFRVFHA.928@.TK2MSFTNGP15.phx.gbl...
>> use the VS debugger and step through it...
>>
>> --
>> Curt Christianson
>> Site & Scripts: http://www.Darkfalz.com
>> Blog: http://blog.Darkfalz.com
>>
>>
>> <dl> wrote in message news:OCp9zDRVFHA.1508@.tk2msftngp13.phx.gbl...
>> > 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.AppSett ings["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)Excep tion1;
>> > //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.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
>>>> > --
>>>>>
>>
Sorry, problem fixed, -- Wrong control type (HTML controls are used rather
than the Web controls).

<dl> wrote in message news:OCp9zDRVFHA.1508@.tk2msftngp13.phx.gbl...
> 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.AppSett ings["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)Excep tion1;
> //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.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
>
> --
Guess you were not declaring them properly
Patrick

*** Sent via Developersdex http://www.developersdex.com ***

0 comments:

Post a Comment