Solved

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Posted on 2014-10-07
9
82 Views
Last Modified: 2015-09-19
I am getting this error -

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

On this line of code -

lblFirstName.Text = txtboxFirstName.Text.ToString();

Open in new window


Any idea on what is wrong or how I should resolve this?
0
Comment
Question by:thinklings
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 

Author Comment

by:thinklings
ID: 40367434
This is the entire function, if needed -

 protected void Wizard1_ActiveStepChanged(object sender, EventArgs e)
        {

			//Pass on name from Section A to Section B
            if (Wizard1.ActiveStep.ID == "Step2")
            {
                lblFirstName.Text = txtboxFirstName.Text.ToString();
                lblLastName.Text = txtboxLastName.Text.ToString();
            }

            //Check Proof of Eligibility
            if (Wizard1.ActiveStep.ID == "Step3")   
            {
                if ((rbOption.SelectedValue="Option1") || (rbOption.SelectedValue="Option2"))
                {
                    if (txtboxRefereeName.Text == "" || txtboxROrg.Text == "" || txtboxRRole.Text == "" || txtboxREmail.Text == "" || txtboxRPhone.Text == "")
                    {
                        Wizard1.ActiveStepIndex = 1;
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Script", "alert('If you selected Option 1 OR 2, You must provide Referee Details. All fields are MANDATORY in REFEREE DETAILS section.');", true);
                    }
                    else
                    {
                        Wizard1.ActiveStepIndex = 2;
                    }
                }


                else
                    if ((rbOption.SelectedValue="Option1") || (rbOption.SelectedValue="Option2") || (rbOption.SelectedValue="Option3")))
                    {
                        Wizard1.ActiveStepIndex = 2;
                    }
                    else
                    {
                        Wizard1.ActiveStepIndex = 1;
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Script", "alert('You must provide Proof of Eligibility by selecting one option.');", true);
                    }
            }

            //Check option for Product Selection
            if (Wizard1.ActiveStep.ID == "Step4")
            {
                if (rbSelectedProduct.SelectedItem != null)
                {
                    Wizard1.ActiveStepIndex = 3;
                }
                else
                {
                    Wizard1.ActiveStepIndex = 2;
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Script", "alert('Please select your Smoke Alarm');", true);
                }
            }


            // Condition to Check one Radio button to for Payment Option
            if (Wizard1.ActiveStep.ID == "Step4")   
            {
                if (creditcard.Checked)
                {
                    if (lblAuthCode.Text.ToString() == "")
                    {
                        Wizard1.ActiveStepIndex = 2;
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Script", "alert('Your CreditCard Payment has not been done. Please process payment and complete the transaction OR select other payment option.');", true);
                    }
                    else
                    {
                        Wizard1.ActiveStepIndex = 3;
                    }
                
                
                }


                else
                    if ((cash.Checked) || (chequeMO.Checked) || (eft.Checked) || (creditcard.Checked) || (WithEvidence.Checked) || (WithoutEvidence.Checked))
                    {
                        Wizard1.ActiveStepIndex = 3;
                    }
                    else
                    {
                        Wizard1.ActiveStepIndex = 2;
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Script", "alert('Please select one option.');", true);
                    }
            }

           
        }

Open in new window

0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 40367459
Looks like one of your controls is declared but does not exist (not initialised?).
0
 

Author Comment

by:thinklings
ID: 40367472
It looks like I am having this problem with the whole file and different functions within the same aspx.cs file. I don't believe it is regarding a specific control - could something else be broken or missing?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:thinklings
ID: 40367479
I am also getting the error "The name '<control name>' does not exist in the current context" on all of the controls but the application still compiles. Not sure if this helps?
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 40367501
Strange, no idea...
0
 

Author Comment

by:thinklings
ID: 40367509
Do you know how I am able to force the generation of the designer file?
0
 

Accepted Solution

by:
thinklings earned 0 total points
ID: 40367541
Never mind, I found how.
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 40976956
No objections, of course.

But it might be useful for some people what was the problem.

Could you please share what was the problem and how did you solve it?
0
 

Author Closing Comment

by:thinklings
ID: 40984553
All sorted.
0

Featured Post

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question