![]() |
| ||
| Transferring Variables 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 |
| ||
| Re: Transferring Variables just create your fields after your class declaration before any event handlers, then you can reach them from everywhere in your codefile |
| ||
| Re: Transferring Variables I don't know what you mean by Class Declaration, but what I have is: <html><head><script language="VB" runat="server"> How can I transfer that variable DayNum from the Sub Page_Load to the Sub Btn_Click? |
| ||
| Re: Transferring Variables why dont you use code behind files? are you migrating from classical asp or php? |
| ||
| Re: Transferring Variables Yes, I'm migrating from PHP. Is there anyway I can do this without using Code Behind files, or will I have to? |
| ||
| Re: Transferring Variables 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. |
| ||
| Re: Transferring Variables 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 Quote:
|
| All times are GMT -4. The time now is 1:42 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC