473,471 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 16 '05 #1
1 5308
"Davids" <db****@simnet.is> a écrit dans le message de news:
d0**********@news.simnet.is...
found it...
what I forgot to do was to instantiate an inherited masterpage class:


You don't have to instantiate a class to create a 'global' variable; simply
use a static string field instead of an instance field.

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

Then to use it you refer to :

MP_Master.MyString

Joanna

--
Joanna Carter
Consultant Software Engineer
Nov 16 '05 #2

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

Similar topics

9
by: Charley Kyd | last post by:
I'm a newbie who needs advice about how to use external files of JavaScript code. I spent an hour this afternoon browsing through JavaScript books at the local book store. In about 15 different...
15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
10
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of...
2
by: Davids | last post by:
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"; } ...
3
by: Pierre | last post by:
Hello, In an aspx page (mypage.aspx) from a web projet, I would like to get the value of a variable of the projet that is declared as public in a module. The variable can be called from...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
3
by: Frank | last post by:
Hi, I simply wish to code a JS function ONCE, in a .js file, include the .js file in the Master page, and then in several but not all pages, I wish to execute the function on pageload. I...
3
by: seanacais | last post by:
I'm trying to build an unknown number of repeating gui elements dynamically so I need to store the variables in a list of dictionaries. I understand that Scale "variable" name needs to be a...
2
by: Kevin | last post by:
I am having difficulty updating a variable page-time-stamp in the following snippit. The variable time-stamp is initialized from the attribute time-stamp from the log element. Some of the page...
1
by: Matty J | last post by:
Excellent, thanks Nathan. The problem I'm having is that I want the variable set in the *Master* page base class. Setting the variable in the Master Base Class Page_PreInit event doesn't seem to...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.