|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Object reference not set to an instance of an object - newpostAny 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 -- use the VS debugger and step through it....
Show quoteHide quote <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.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 > > > -- > > > I don't have VS yet ?! will VWD2005 express do it? any other ways to do it?
Show quoteHide quote "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePonews: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.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 > > > > Show quoteHide quote > > 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 > > > > > > -- > > > > > > > > well, start taking out and putting back in some of the code till you limit
it down Show quoteHide quote <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.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 >> > >> > >> > -- >> > >> > >> > >> >> > > Sorry, problem fixed, -- Wrong control type (HTML controls are used rather
than the Web controls). Show quoteHide quote <dl> wrote in message news:OCp9zDRVFHA.1508@tk2msftngp13.phx.gbl... (System.Runtime.InteropServices.COMException)Exception1;> 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 = > Show quoteHide quote > //ConsoleWriteline(COMEx.ErrorCode); System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo> } > > //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 > > Show quoteHide quote > 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 > > > -- > > > |
|||||||||||||||||||||||