Solved

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

Posted on 2014-10-07
9
78 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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