Go Back   Velocity Reviews > General Computer Discussion > Software
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
Old 09-06-2006, 04:00 PM   #1
Thumbs up Variable Scope in asp.Net


Hi
I have one problem with using variables in asp.net with C# application. I declared one variable as public and initialized the value for the variable in one event and when calling the value in another event it returns zero in that event. So plz help me hw to call the value in that event.

EXample Code
public int MyRowcount; // Variable Initialization

public void Button1_Click(object sender, System.EventArgs e)
{
MyRowcount=5; //assigning Value to the variable
}
public void Button2_Click(object sender, System.EventArgs e)
{

Response.Write(MyRowcount); //It returns zero value(I want it should return 5)
}

advance in thanks
Jansi Rajkumar. T
}


jansi_rk
jansi_rk is offline   Reply With Quote
Old 09-18-2006, 06:05 PM   #2
BabuA
Junior Member
 
Join Date: Sep 2006
Location: BANGALORE,INDIA
Posts: 6
Default
Hi Jansi_rk,

if you delclare your variable with static modifier, then it will be available to all the events with in the scope availabe, as follows

public static int MyRowcount;

Babu


BabuA
BabuA is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
viewstate MAC failed in asp.net 2.0 while postback the page azraffarveen Software 0 05-12-2009 03:24 PM
.NET 2.0 Web Apps / .NET 3.5 ASP.NET Apps - Differences/Similariti london1919 MCTS 1 12-08-2008 03:16 PM
ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method) msandlana Software 0 04-25-2008 06:37 AM
Variable scope toller Hardware 1 04-21-2008 08:28 PM
ASP.NET 2.0 application does not run in WIN2k3 johnfraj Software 0 04-19-2007 08:27 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46