473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

using a global variable set by master page

I am not having any success, in my master.cs page I assign a variable to be
used within all other pages:

public partial class MP_master
{
public string MyString = "this string is global";
}

well accessing it from other pages brings a "CS0103: The name 'MyString'
does not exist in the current context
" error?
Nov 19 '05 #1
2 4752
Hi Davids:

The MyString field isn't really 'global' in the sense that you still
need an instance of MP_master to access the field. Perhaps you want to
mark MyString with the static keyword and associate the field with the
type? i.e: MP_master.MyString

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 2 Mar 2005 16:24:57 -0000, "Davids" <db****@simnet.is> wrote:
I am not having any success, in my master.cs page I assign a variable to be
used within all other pages:

public partial class MP_master
{
public string MyString = "this string is global";
}

well accessing it from other pages brings a "CS0103: The name 'MyString'
does not exist in the current context
" error?


Nov 19 '05 #2
found it...
what I forgot to do was to instantiate an inherited masterpage class:

MP_master masterpage = new MP_Master();
and then

masterpage.string = ...
"Davids" <db****@simnet.is> wrote in message
news:d0**********@news.simnet.is...
I am not having any success, in my master.cs page I assign a variable to be
used within all other pages:

public partial class MP_master
{
public string MyString = "this string is global";
}

well accessing it from other pages brings a "CS0103: The name 'MyString'
does not exist in the current context
" error?

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: chellappa | last post by:
hi Everybody ! decalaring variable in a.h and using that vaaariable in a1.c and inalization is in main.c it is possible .........pleaase correct that error is it Possible? i am trying it...
0
by: Andrew Polo | last post by:
Dear Sirs, I'm using Navigation Menu control on one of my Web Pages (.NET Framework 2.0). Everything is fine as far as I'm not using it within Master Page. If I make my page as a context of Master...
2
by: Jeff | last post by:
hey asp.net 2.0 I've placed a LoginStatus control on a master page (so I don't need to have it on every webpage) in my project. When I click on this control to logout, I get this error: A...
2
by: Argirop | last post by:
I have a page Default.aspx. Its first line is the following: <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="default.aspx.cs"...
4
by: brett | last post by:
I have an ASPX page that needs to use a FORM. However, it's master page already has a FORM element, which prevents the ASPX page from using its FORM element. I'm not doing anything special on the...
0
by: bednar.tomas | last post by:
Is there any way 2 do that? Am just designing master page and I want 2 leave it doing it automaticaly... something like <currentpage:title/>... Thanx Tomas B.
1
by: Asif | last post by:
Hi All, I did follow the MSDN article (http://msdn2.microsoft.com/en-us/ library/ms379585(VS.80).aspx ) for overriding Master Page properties by setting page title and other Meta information(...
0
by: malay1986 | last post by:
Hello everybody, I want to use frame in master page in asp.net 2.0 U can see for example "http://msdn2.microsoft.com/hi-in/library/default.aspx" exactly what i want. Please help me.
10
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, Trying to create a master page that holds a menu, and the menu switches between pages in the site. 2 problem arrosed: a. When I navigate from page to page (all AJAX Web Forms, with the...
1
by: raghulvarma | last post by:
I have created a master page <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.