i have declared a variable in page_load function and i want to use this variable in Button_click function

i declare the variable globle but its not working and i also passed the variable by value but then Button_click funcion is showing error that syntax is incorrect


wat to do ???

(variables get lost with postback)
You can use hiddenfield to store the value of your variable
or you can use session variables
setvalue:
Session("myvariable")=somevalue
retreive value:
somevalue=Session("myvariable")
Or you can use viewstate

Did you try using global variables ?
I don't remember but I think stay within postbacks

You can use session.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.