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 8403451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:20:56+00:00 2026-06-09T22:20:56+00:00

I have a master page and a child page (page using master page). I

  • 0

I have a master page and a child page (page using master page).

I have a class/function that I call from the child page (like this):

new MasterPageSiteWide().setGeoAndLanguage(ViewState["_country"].ToString(), _lang);

This calls the function (as when I step through it executes the values).

On the master page I have:

public partial class MasterPageSiteWide : System.Web.UI.MasterPage
{
    public string _closeTimeType;
    public string _langForCalendar;

    public void setGeoAndLanguage(string nation, string lang)
    {
        string globalresourcestring = string.Empty;
        _langForCalendar = (String)GetGlobalResourceObject("share", "lblCalendarLang");

        switch (nation.ToUpper())
        {
            case "USA":
                ViewState["geo"] = "USA";
                ViewState["langID"] = 1;
                _closeTimeType = "PTPA";
                break;
            case "CAN":
                if (lang.ToUpper() == "FR")
                {
                    ViewState["geo"] = "CAN";
                    ViewState["langID"] = 2;
                    _closeTimeType = "CANPA";
                }
                else
                {
                    ViewState["geo"] = "CAN";
                    ViewState["langID"] = 1;
                    _closeTimeType = "CANPA";
                }
                break;
            case "MEX":
                ViewState["geo"] = "MEX";
                ViewState["langID"] = 3;
                _closeTimeType = "MEXPA";
                break;
            default:
                ViewState["geo"] = "USA";
                ViewState["langID"] = 1;
                _closeTimeType = "PTPA";
                break;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

When the code steps through it sets the variables _closeTimeType and _langForClaendar (I can see the values).

But when it goes back to the child page those values are null. I am accessing them like this:

Master._closeTimeType

Also the ViewState variables are null after the master page is loaded.

NOTE: I do have this line on the .aspx page:

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

Why are the variables not keeping the values I am setting?

  • 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-06-09T22:20:58+00:00Added an answer on June 9, 2026 at 10:20 pm

    Based on your example, I think you may be unintentionally instantiating an additional master page, when in reality you want to call the functions on the master page upon which the existing page instance is based. You might try something akin to the following cast from the child page:

    ((MasterPageSiteWide)this).setGeoAndLanguage(ViewState["_country"].ToString(), _lang);
    

    You may also be able to just try it directly, eg

    Master.setGeoAndLanguage(ViewState["_country"].ToString(), _lang);
    

    That should call the master page function from the current page instance, and cause the page to behave as you expect (preserving the values). Hope that helps.

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

Sidebar

Related Questions

I'd like to have a page that uses a child master page, fill in
Hii, I have function established in child page, that is using in the childpages.
I have a master page called SampleMaster.master and this page contains a Repeater control
I have one master page which applies to all pages in this website. On
I have a master page in C#, where I have this code: <div style=width:
I have a master page in my asp.net MVC project, which has code like
I have a master page with a bunch of menu like: <ul id=ulMenu runat=server>
i have a master page called layout.cshtml and a page called testpage.cshtml. On this
I have code like the following: <s:VGroup gap=10 id=group height=100%> <s:Label text=This is page
I have a child page (using masterpages) where I want to include a regular

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.