473,493 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Simple Pulbic Variable

I'm new. I have an aspx page and I want to declare a public variable
"GroupID" at the top of the page and be able to change the value in
different parts of that particular page. Bascially, how do you creat a
public variable for one page only?
Thanks!
Nov 27 '07 #1
7 1013
If you want to use it within the page, declare it within the class
definition
like

Private GroupID as Integer

Regards,

Trevor Benedict
MCSD

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
I'm new. I have an aspx page and I want to declare a public variable
"GroupID" at the top of the page and be able to change the value in
different parts of that particular page. Bascially, how do you creat a
public variable for one page only?
Thanks!

Nov 27 '07 #2
Perfect! Thanks!

"Trevor Benedict" <Tr********@yahoo.comwrote in message
news:OW**************@TK2MSFTNGP06.phx.gbl...
If you want to use it within the page, declare it within the class
definition
like

Private GroupID as Integer

Regards,

Trevor Benedict
MCSD

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>I'm new. I have an aspx page and I want to declare a public variable
"GroupID" at the top of the page and be able to change the value in
different parts of that particular page. Bascially, how do you creat a
public variable for one page only?
Thanks!


Nov 28 '07 #3
Is this by design....

When I have an onclick of a control, it assigns the public variable a value.
When I click on another control, the value is gone from the public variable?
Am I not sticking the public variable in the right place. This is where I
have it in my code behind...

Imports System.Data, System.Data.SqlClient

Partial Class Client_ClientMtgNote

Inherits System.Web.UI.Page

Public groupid As Integer

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load


"Trevor Benedict" <Tr********@yahoo.comwrote in message
news:OW**************@TK2MSFTNGP06.phx.gbl...
If you want to use it within the page, declare it within the class
definition
like

Private GroupID as Integer

Regards,

Trevor Benedict
MCSD

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>I'm new. I have an aspx page and I want to declare a public variable
"GroupID" at the top of the page and be able to change the value in
different parts of that particular page. Bascially, how do you creat a
public variable for one page only?
Thanks!


Nov 28 '07 #4
pvong,

A webpage is not persisitent, in other words, all information in the class
will be destroyed at the moment that you send the page.

To make things global for a page of a certain user there are 3 methods, for
which in my idea the session.item is in most cases the most effective to
use.

Cor

Nov 28 '07 #5


"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:A6**********************************@microsof t.com...
pvong,

A webpage is not persisitent, in other words, all information in the class
will be destroyed at the moment that you send the page.

To make things global for a page of a certain user there are 3 methods,
for which in my idea the session.item is in most cases the most effective
to use.

Cor
Session isn't for the one page only though, as the OP wants. Granted, he
can get at it in the single page, but it is scoped for the entire session
for all pages under a single site.

OP:
To store a value for the current user for the current page, you'd want to
use something like the ViewState.

ViewState("MyPropertyName") = MyValue

HTH,
Mythran
Nov 28 '07 #6
Mytrhan,

The way you describe it can in my idea bemisunderstood. A session is for all
pages, however not for all users. As long as you don't use an item on
another page, then it is for one page.

You describe in my idea in a way the status of a static class and the cache
from ASP.NET. To a user belongs the session and the vieuwstate as you wrote.
The session does not for nothing use the cookie.

The problem with a viewstate is that it is transported over the InterNet and
can make the transaction long.

Cor

"Mythran" <ki********@hotmail.comschreef in bericht
news:7D**********************************@microsof t.com...
>

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:A6**********************************@microsof t.com...
>pvong,

A webpage is not persisitent, in other words, all information in the
class will be destroyed at the moment that you send the page.

To make things global for a page of a certain user there are 3 methods,
for which in my idea the session.item is in most cases the most effective
to use.

Cor

Session isn't for the one page only though, as the OP wants. Granted, he
can get at it in the single page, but it is scoped for the entire session
for all pages under a single site.

OP:
To store a value for the current user for the current page, you'd want to
use something like the ViewState.

ViewState("MyPropertyName") = MyValue

HTH,
Mythran

Nov 28 '07 #7
Thanks you both. I will use a Session and clear it on page load not
postback.

Phil

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:A6**********************************@microsof t.com...
pvong,

A webpage is not persisitent, in other words, all information in the class
will be destroyed at the moment that you send the page.

To make things global for a page of a certain user there are 3 methods,
for which in my idea the session.item is in most cases the most effective
to use.

Cor

Nov 28 '07 #8

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

Similar topics

15
417
by: Alex | last post by:
could somebody tell me the difference between those two styles: function abc(var1, var2){ /* logic in here */ } and abc = function(var1, var2){ /* logic in here */ }; When / why would I...
2
1977
by: megandelune | last post by:
I have been learning ASP from a book I bought a week ago and so far it is very informative, but I seem to be confused on one simple term. Variant. Now I learned how to declare a varible with the...
0
7528
by: Tal Sharfi | last post by:
Hi everyone I recently had the need for StringGrid object same as the one that Delphi has. An object that helps show lists of other objects in a simple grid. I searched the news groups and...
5
1791
by: Logickle | last post by:
Hi, all. I'm working on an application which requires communicating session info between separate web apps running on the same web server. The out of process server method sounded ideal, and...
4
2217
by: Phillip Vong | last post by:
I'm a newbie using VS2005 to learn and test. I'm testing against the Northwind DB. I created a simple variable called "myVariable" and I assigned it the character "c". I want my SQL query to use...
41
2040
by: SkyBlue | last post by:
Hi, can someone explain why the following simple C code segfaulted? I've stared it for 30mins but couldn't find the problem. Thx in advance #include <stdio.h> int main() { char *one; char...
3
2456
by: deejayquai | last post by:
Hello Simple one this I guess, but I'm quite stuck at the moment. I would like to update the records displayed in my listbox (lstStudents) using criteria selected from my combo (cboForm) in a...
1
2056
by: astrogirl77 | last post by:
I'm new to C++ and am hoping to find help with coding a simple C program, am wanting to obtain code and functioning exe's. I code in an old version of Visual Basic 4.0, I have a simple app that...
25
4509
by: Brian | last post by:
I have a datetimepicker formated for just time, the user selects the time. I want to compare if that time is between midnight and 8 am dtmTime #11:59:59 PM# and dtmTime < #08:00:00 AM# this...
0
7119
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
6989
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
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6873
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
7367
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...
0
4579
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
3088
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
1400
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 ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.