Error:Object reference not set to an instance of an object
-
public partial class _User : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { try { if (!PreviousPage.IsValid) { LabelName.Text = "Error"; } else { TextBox textboxitem = (TextBox)PreviousPage.FindControl("TXtLoginName"); String user = textboxitem.Text; String pswd = ((TextBox)PreviousPage.FindControl("TxtLoginPswd")).Text; LabelName.Text = String.Format("Hai...{0}<br/>Ur password is {1}", user, pswd); } } catch (Exception err) { LabelName.Text = "Error: " + err.Message.ToString(); } } } my previous page contains textbox, TXtLoginName.Text & TxtLoginPswd ERROR:Object reference not set to an instance of an object. Whats the fault?
-
public partial class _User : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { try { if (!PreviousPage.IsValid) { LabelName.Text = "Error"; } else { TextBox textboxitem = (TextBox)PreviousPage.FindControl("TXtLoginName"); String user = textboxitem.Text; String pswd = ((TextBox)PreviousPage.FindControl("TxtLoginPswd")).Text; LabelName.Text = String.Format("Hai...{0}<br/>Ur password is {1}", user, pswd); } } catch (Exception err) { LabelName.Text = "Error: " + err.Message.ToString(); } } } my previous page contains textbox, TXtLoginName.Text & TxtLoginPswd ERROR:Object reference not set to an instance of an object. Whats the fault?
M.Ambigai wrote:
ERROR:Object reference not set to an instance of an object.
This is very common error. Did you debug your application? Check which line throwing the exception.
cheers, Abhijit CodeProject MVP My Recent Article : Exploring Session in ASP.Net
-
public partial class _User : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { try { if (!PreviousPage.IsValid) { LabelName.Text = "Error"; } else { TextBox textboxitem = (TextBox)PreviousPage.FindControl("TXtLoginName"); String user = textboxitem.Text; String pswd = ((TextBox)PreviousPage.FindControl("TxtLoginPswd")).Text; LabelName.Text = String.Format("Hai...{0}<br/>Ur password is {1}", user, pswd); } } catch (Exception err) { LabelName.Text = "Error: " + err.Message.ToString(); } } } my previous page contains textbox, TXtLoginName.Text & TxtLoginPswd ERROR:Object reference not set to an instance of an object. Whats the fault?
you must be having this error in retrieving password value right?? when ever page is post back password values are disappead for security issues... in your case if you want to use password value on next page then you will have to save its value... txtpassword.attibutes["value"]= txtpassword.text; now your value of password textbox on post back will not lost and use use it where ever you want...
umerumerumer
modified on Tuesday, February 3, 2009 4:26 AM
-
you must be having this error in retrieving password value right?? when ever page is post back password values are disappead for security issues... in your case if you want to use password value on next page then you will have to save its value... txtpassword.attibutes["value"]= txtpassword.text; now your value of password textbox on post back will not lost and use use it where ever you want...
umerumerumer
modified on Tuesday, February 3, 2009 4:26 AM
Let him do the experiment. ;)
cheers, Abhijit CodeProject MVP My Recent Article : Exploring Session in ASP.Net