Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6103529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:44:21+00:00 2026-05-23T13:44:21+00:00

Attempting something like public string MyText { get {return lbl.Text;} set {lbl.Text = value;}}

  • 0

Attempting something like

public string MyText { get {return lbl.Text;} set {lbl.Text = value;}}

taken from this question ends in an exception:

public string change_ddlArea { get { return ddlArea.SelectedItem.Text; } set { ddlArea.Items.FindByValue(value).Selected = true; } }

–> Object reference not set to an instance of an object.

Using these normally cause the same error:

this.ddlEnergyType.Items.FindByValue(resourceTypeVal).Selected = true;
((DropDownList)Master.FindControl("ddlArea")).Items.FindByValue("all").Selected = true;

I’m having difficulty finding an answer to this problem on google. It should work, given if a label manipulation does, moving to a ddl would as well?

The one difference that could be the problem is when trying to call this.. (in the 2nd code block) I use

Master.change_ddlArea = sendoff_area;

and in the aformentioned link it is done like so

((MasterPageTypeName)Page.MasterPage ).MyText = "test";
//so mine would look like this:
((GAWMaster)_default.Master).change_ddlArea = "all";

however intellisense is missing the ‘.Master’ – putting it in causes the information to appear: an object reference is required for the non-static field, method or property….

tl,dr: halp

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:44:22+00:00Added an answer on May 23, 2026 at 1:44 pm

    Your question is VERY confusing to say the least. It’s very simple to do what your title is asking:

    First in your MasterPage code behind do:

    public string change_ddlArea
    {
        get { return ddlArea.SelectedItem.Value; }
        set { ddlArea.Items.FindByValue(value).Selected = true; }
    }
    

    Then in your child page define your MasterPage type so that it can ‘see’ the change_ddlArea property of the MasterPage. See here for more reference info.

    <%@ MasterType virtualPath="~/MasterPage.master"%>
    

    Then in your code on your child page you should be able to just do:

    Master.change_ddlArea(someValue); 
    

    The value you are setting MUST exist or you will get an object reference error. Make sure your DropDownList is loaded correctly and you are not doing things out of order. Also, if your not using ViewState and doing a PostBack, make sure you have rebuilt your DropDownList before setting the value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to inline css from a stylesheet in c#. Like how this works.
Basically I would like to do something like this at the top of my
I am attempting to do something simple (I thought) - securing my application using
I'm attempting to do something which should be relatively simple. I'm using a ListView
Attempting to print out a list of values from 2 different variables that are
Attempting to deploy a MOSS solution to a UAT server from dev server for
When attempting to compile my C# project, I get the following error: 'C:\Documents and
When attempting to call functions in math.h , I'm getting link errors like the
I would like to marshall Java objects into XML and vice-versa from within an
I am attempting to pull some information from my tnsnames file using regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.