473,409 Members | 1,934 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,409 software developers and data experts.

Newb problem with Flag variables

Hello
I want to create a link that open and close a panel. but i can't save a
variable as a flag to test each time if the panel is open or not, this is my
code :
int flag=0;
private void LinkButton1_Click(object sender, System.EventArgs e)
{
if(flag==0)
{ Panel1.Visible=true;
Panel1.Enabled=true;
flag=0; }
else{
Panel1.Visible=false;
Panel1.Enabled=false;
flag=1;
}}

the problem is Flag varibale that when ever i push the link the page reload
so the value resets to 0 again. how can i use global variables that don't
change whit refreshing page?
i know i can use database but that's not the way to solve on such a simple
page. i also tried Session but it has the same problem, resets whenever
page refresh(or link gets click).

Thanks
Nov 18 '05 #1
2 1310
Hi,
you can check for state of Panel1.Visible or you can just
add in LinkButton1_Click following:
Panel1.Visible = !Panel1.Visible;

Best,

Svetlin Grancharov
-----Original Message-----
Hello
I want to create a link that open and close a panel. but i can't save avariable as a flag to test each time if the panel is open or not, this is mycode :
int flag=0;
private void LinkButton1_Click(object sender, System.EventArgs e){
if(flag==0)
{ Panel1.Visible=true;
Panel1.Enabled=true;
flag=0; }
else{
Panel1.Visible=false;
Panel1.Enabled=false;
flag=1;
}}

the problem is Flag varibale that when ever i push the link the page reloadso the value resets to 0 again. how can i use global variables that don'tchange whit refreshing page?
i know i can use database but that's not the way to solve on such a simplepage. i also tried Session but it has the same problem, resets wheneverpage refresh(or link gets click).

Thanks
.

Nov 18 '05 #2
About second question you can put somewhere on the page:
<input id="HiddenValue" type=hidden value="" runat=server>

and after that with code set the value with:

HiddenValue.Value = "value"

or you can read the value with

var = HiddenValue.Value

Best

Sve
-----Original Message-----
Hello
I want to create a link that open and close a panel. but i can't save avariable as a flag to test each time if the panel is open or not, this is mycode :
int flag=0;
private void LinkButton1_Click(object sender, System.EventArgs e){
if(flag==0)
{ Panel1.Visible=true;
Panel1.Enabled=true;
flag=0; }
else{
Panel1.Visible=false;
Panel1.Enabled=false;
flag=1;
}}

the problem is Flag varibale that when ever i push the link the page reloadso the value resets to 0 again. how can i use global variables that don'tchange whit refreshing page?
i know i can use database but that's not the way to solve on such a simplepage. i also tried Session but it has the same problem, resets wheneverpage refresh(or link gets click).

Thanks
.

Nov 18 '05 #3

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

Similar topics

3
by: martin | last post by:
A page has links that want to invoke the same php file, but pass in different values for a given variable. <a href=process.php?flag=1> Do One </a> <a href=process.php?flag=2> Do Two </a> <a...
10
by: Mark H | last post by:
Hey all-- I'm building a database and I basically need to keep out people who aren't authorized, but it's not like I need top security here. I'm just doing basic user/pass of a SQL database, and...
5
by: Alexandre | last post by:
Hi, Im a newb to dev and python... my first sefl assigned mission was to read a pickled file containing a list with DB like data and convert this to MySQL... So i wrote my first module which...
15
by: Michael | last post by:
Do expicit pointers exist in python?? if i do: a = b = a a.empty() b = ?
0
by: Norm Wong | last post by:
If anyone is interested in using db2uext2 with Cygwin gcc compiler on Windows, I've modified the IBM provided sample with the attached file. There are two main modifications. The mkdir command...
5
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
6
by: Niklaus | last post by:
Hi, Can someone point out what is wrong with this code ? How can i make it better optimize it. When run it gives me seg fault in linux. But windows it works fine(runs for a long time). Do we...
24
by: Apotheosis | last post by:
The problem professor gave us is: Write a program which reads two integer values. If the first is less than the second, print the message "up". If the second is less than the first, print the...
89
by: Tubular Technician | last post by:
Hello, World! Reading this group for some time I came to the conclusion that people here are split into several fractions regarding size_t, including, but not limited to, * size_t is the...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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...
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...
0
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...

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.