Hi,

I have a really quick question. I have Sub Page_Load(...), and in that sub, I set a couple of variables. In a form, further down the page, in the <body> tag, I have a button, set so when I click it, it operates another Sub, Btn_Click(...). How can I access the variable I set in Page_Load in Btn_Click without using a URL transfer method?

Thanks

George

just create your fields after your class declaration before any event handlers, then you can reach them from everywhere in your codefile

I don't know what you mean by Class Declaration, but what I have is:

<html><head><script language="VB" runat="server">
Sub Page_Load(s As Object, e As EventArgs)
Dim DayNum As Integer
DayNum = 3

End Sub

Sub Btn_Click(s As Object, e As EventArgs)

Response.Write(DayNum)

End Sub
</script>
</head><body>
... HTML ... </body>
</html>

How can I transfer that variable DayNum from the Sub Page_Load to the Sub Btn_Click?

why dont you use code behind files? are you migrating from classical asp or php?

Yes, I'm migrating from PHP. Is there anyway I can do this without using Code Behind files, or will I have to?

yes you can do it without codebehind files but after a while you will confront them everywhere so that will be inevitable. asp.net is organized in code behind manner so just use them.

Sub Page_Load(s As Object, e As EventArgs)
Dim DayNum As Integer
DayNum = 3
Session["DayNum"] = DayNum;

End Sub

Sub Btn_Click(s As Object, e As EventArgs)

Response.Write(System.Convert.ToInt32(Session["DayNum"]));

Session["DayNum"] = null;
End Sub

yes you can do it without codebehind files but after a while you will confront them everywhere so that will be inevitable. asp.net is organized in code behind manner so just use them.