tags:

views:

140

answers:

1

Say in my codebehind .cs file, I set a variable:

protected void Page_Load(object sender, EventArgs e)
{
    int x = 2;
}

I want to display this dynamically in my aspx page. But this code won't work:

<% Response.Write(x); %>

How can i accomplish this? Is there any way to pass variables?

+10  A: 

Your variable only exists in the Page_Load mehtod.

Declare it at the class level, set it in the Page_Load.

Brandon