Solved

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

Posted on 2014-10-07
9
65 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
  • 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 29

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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 29

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 29

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now