Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error:Object reference not set to an instance of an object

Error:Object reference not set to an instance of an object

Scheduled Pinned Locked Moved ASP.NET
designhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M Ambigai
    wrote on last edited by
    #1

    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?

    A M 2 Replies Last reply
    0
    • M M Ambigai

      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?

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • M M Ambigai

        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 Offline
        M Offline
        mr_muskurahat
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • M mr_muskurahat

          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

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          Let him do the experiment. ;)

          cheers, Abhijit CodeProject MVP My Recent Article : Exploring Session in ASP.Net

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups