?
Solved

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

Posted on 2014-10-07
9
Medium Priority
?
84 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
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

 

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 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