Solved

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

Posted on 2014-10-07
9
73 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

24 Experts available now in Live!

Get 1:1 Help Now