| |

VerySource

 Forgot password?
 Register
Search
View: 624|Reply: 5

Modify the value of a global variable in the page

[Copy link]

3

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-7 14:30:02
| Show all posts |Read mode
Define a global variable int a = 7;
Using Response.Write (a) in the From_Load event, it prints 7
Change its value in the Button_Click event, set a = 8, how to make the page display the new value after the Button_Click event?
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-24 23:45:01
| Show all posts
Add the following to Button_Click:
{
a = 8;

From_Load (null, null);
}
Reply

Use magic Report

0

Threads

8

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-25 10:00:02
| Show all posts
How to make the page display the new value after the Button_Click event?
Then display or assign in this event
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-5-25 13:00:02
| Show all posts
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-5-25 13:15:01
| Show all posts
Define a like this;

int a
{
 get
 {
    return ViewState ["i"] == null? 0: (int) ViewState ["i"];
 }
set
{
 ViewState ["i"] = value;
}
}
Reply

Use magic Report

3

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-28 10:30:01
| Show all posts
burtmao, try it yourself first and then make a conclusion
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list