Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Pass variables value between diferent pages

Reply
Thread Tools

Pass variables value between diferent pages

 
 
ruca
Guest
Posts: n/a
 
      02-26-2004
Hi,
How can I pass the values of some variables from page1.aspx to page2.aspx?
I try to define some variables in page2 and then when I click a button in
page1 it will fill that variables (in page2) with values. The proble is that
when I call page2 variable values are NULL.

Like this:

-------------------------------BEGIN
CODE-----------------------------------------------

Imports AppName.ClassNamePage2

Dim m_Page2 as New ClassNamePage2

Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.ServerClick

//This values are in a DataSet and are correct (I debug them)

m_Page2.m_lIdHrq = CLng(ds.Tables("Dados").Rows(0).Item("IdLevel"))
m_Page2.m_lNivelHrq = CLng(ds.Tables("Dados").Rows(0).Item("Level"))
m_Page2.m_strFnc = CStr(ds.Tables("Dados").Rows(0).Item("Name"))

//this value it is given from a dropdownlist (I check it, and it returns
the right value)
m_Page2.m_lIdFnc = CLng(UserName.SelectedItem.Value.ToString())

Response.Redirect("Page2.aspx")

//When opens page2.aspx the values are NULL

End Sub
-------------------------------END
CODE-----------------------------------------------

How can I solve this?


--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


 
Reply With Quote
 
 
 
 
Sarmad Aljazrawi
Guest
Posts: n/a
 
      02-26-2004
Since you are redirecting then the easiest way is to send them as parameters
(Querystrings)

response.redirect("Page2.aspx?m_lIdHrq="& m_Page2.m_lIdHrq &"&m_lNivelHrq="&
m_Page2.m_lNivelHrq &"&m_strFnc="& m_Page2.m_strFnc)

or you can use Session variables.

regards,
--
Sarmad Aljazrawi
B.Sc. Computer Science, MSDBA, MCP
www.aljazrawi.net


"ruca" <(E-Mail Removed)> wrote in message
news:OXzXtNF$(E-Mail Removed)...
> Hi,
> How can I pass the values of some variables from page1.aspx to page2.aspx?
> I try to define some variables in page2 and then when I click a button in
> page1 it will fill that variables (in page2) with values. The proble is

that
> when I call page2 variable values are NULL.
>
> Like this:
>
> -------------------------------BEGIN
> CODE-----------------------------------------------
>
> Imports AppName.ClassNamePage2
>
> Dim m_Page2 as New ClassNamePage2
>
> Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.ServerClick
>
> //This values are in a DataSet and are correct (I debug them)
>
> m_Page2.m_lIdHrq = CLng(ds.Tables("Dados").Rows(0).Item("IdLevel"))
> m_Page2.m_lNivelHrq = CLng(ds.Tables("Dados").Rows(0).Item("Level"))
> m_Page2.m_strFnc = CStr(ds.Tables("Dados").Rows(0).Item("Name"))
>
> //this value it is given from a dropdownlist (I check it, and it

returns
> the right value)
> m_Page2.m_lIdFnc = CLng(UserName.SelectedItem.Value.ToString())
>
> Response.Redirect("Page2.aspx")
>
> //When opens page2.aspx the values are NULL
>
> End Sub
> -------------------------------END
> CODE-----------------------------------------------
>
> How can I solve this?
>
>
> --
>
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
>
>



 
Reply With Quote
 
 
 
 
ruca
Guest
Posts: n/a
 
      02-26-2004
I like it more of your second option. Can you give me an example of that. I
presume that I have to set this variables in my GlobaAsa file, right?


--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

"Sarmad Aljazrawi" <anonymous[shylme]@discussions.microsoft.com> escreveu na
mensagem news:eH9fe0F$(E-Mail Removed)...
> Since you are redirecting then the easiest way is to send them as

parameters
> (Querystrings)
>
> response.redirect("Page2.aspx?m_lIdHrq="& m_Page2.m_lIdHrq

&"&m_lNivelHrq="&
> m_Page2.m_lNivelHrq &"&m_strFnc="& m_Page2.m_strFnc)
>
> or you can use Session variables.
>
> regards,
> --
> Sarmad Aljazrawi
> B.Sc. Computer Science, MSDBA, MCP
> www.aljazrawi.net
>
>
> "ruca" <(E-Mail Removed)> wrote in message
> news:OXzXtNF$(E-Mail Removed)...
> > Hi,
> > How can I pass the values of some variables from page1.aspx to

page2.aspx?
> > I try to define some variables in page2 and then when I click a button

in
> > page1 it will fill that variables (in page2) with values. The proble is

> that
> > when I call page2 variable values are NULL.
> >
> > Like this:
> >
> > -------------------------------BEGIN
> > CODE-----------------------------------------------
> >
> > Imports AppName.ClassNamePage2
> >
> > Dim m_Page2 as New ClassNamePage2
> >
> > Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e

As
> > System.EventArgs) Handles Button1.ServerClick
> >
> > //This values are in a DataSet and are correct (I debug them)
> >
> > m_Page2.m_lIdHrq = CLng(ds.Tables("Dados").Rows(0).Item("IdLevel"))
> > m_Page2.m_lNivelHrq = CLng(ds.Tables("Dados").Rows(0).Item("Level"))
> > m_Page2.m_strFnc = CStr(ds.Tables("Dados").Rows(0).Item("Name"))
> >
> > //this value it is given from a dropdownlist (I check it, and it

> returns
> > the right value)
> > m_Page2.m_lIdFnc = CLng(UserName.SelectedItem.Value.ToString())
> >
> > Response.Redirect("Page2.aspx")
> >
> > //When opens page2.aspx the values are NULL
> >
> > End Sub
> > -------------------------------END
> > CODE-----------------------------------------------
> >
> > How can I solve this?
> >
> >
> > --
> >
> > Thank's (if you try to help me)
> > Hope this help you (if I try to help you)
> > ruca
> >
> >

>
>



 
Reply With Quote
 
EricJ
Guest
Posts: n/a
 
      02-26-2004
unless you want to store the variables on an sql server or work cookieless
you don't have to do anithing special

session.add("VarName",Value)
value = session.item("VarName")

hope it helps

eric


"ruca" <(E-Mail Removed)> wrote in message
news:O9ycx6F$(E-Mail Removed)...
> I like it more of your second option. Can you give me an example of that.

I
> presume that I have to set this variables in my GlobaAsa file, right?
>
>
> --
>
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
>
> "Sarmad Aljazrawi" <anonymous[shylme]@discussions.microsoft.com> escreveu

na
> mensagem news:eH9fe0F$(E-Mail Removed)...
> > Since you are redirecting then the easiest way is to send them as

> parameters
> > (Querystrings)
> >
> > response.redirect("Page2.aspx?m_lIdHrq="& m_Page2.m_lIdHrq

> &"&m_lNivelHrq="&
> > m_Page2.m_lNivelHrq &"&m_strFnc="& m_Page2.m_strFnc)
> >
> > or you can use Session variables.
> >
> > regards,
> > --
> > Sarmad Aljazrawi
> > B.Sc. Computer Science, MSDBA, MCP
> > www.aljazrawi.net
> >
> >
> > "ruca" <(E-Mail Removed)> wrote in message
> > news:OXzXtNF$(E-Mail Removed)...
> > > Hi,
> > > How can I pass the values of some variables from page1.aspx to

> page2.aspx?
> > > I try to define some variables in page2 and then when I click a button

> in
> > > page1 it will fill that variables (in page2) with values. The proble

is
> > that
> > > when I call page2 variable values are NULL.
> > >
> > > Like this:
> > >
> > > -------------------------------BEGIN
> > > CODE-----------------------------------------------
> > >
> > > Imports AppName.ClassNamePage2
> > >
> > > Dim m_Page2 as New ClassNamePage2
> > >
> > > Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e

> As
> > > System.EventArgs) Handles Button1.ServerClick
> > >
> > > //This values are in a DataSet and are correct (I debug them)
> > >
> > > m_Page2.m_lIdHrq =

CLng(ds.Tables("Dados").Rows(0).Item("IdLevel"))
> > > m_Page2.m_lNivelHrq =

CLng(ds.Tables("Dados").Rows(0).Item("Level"))
> > > m_Page2.m_strFnc = CStr(ds.Tables("Dados").Rows(0).Item("Name"))
> > >
> > > //this value it is given from a dropdownlist (I check it, and it

> > returns
> > > the right value)
> > > m_Page2.m_lIdFnc = CLng(UserName.SelectedItem.Value.ToString())
> > >
> > > Response.Redirect("Page2.aspx")
> > >
> > > //When opens page2.aspx the values are NULL
> > >
> > > End Sub
> > > -------------------------------END
> > > CODE-----------------------------------------------
> > >
> > > How can I solve this?
> > >
> > >
> > > --
> > >
> > > Thank's (if you try to help me)
> > > Hope this help you (if I try to help you)
> > > ruca
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Sarmad Aljazrawi
Guest
Posts: n/a
 
      02-26-2004
No you don't need to set it up in global.asa you can set it any place in the
application.

session("myvar") = value
value = session("myvar")

--
Sarmad Aljazrawi
B.Sc. Computer Science, MSDBA, MCP
www.aljazrawi.net


"ruca" <(E-Mail Removed)> wrote in message
news:O9ycx6F$(E-Mail Removed)...
> I like it more of your second option. Can you give me an example of that.

I
> presume that I have to set this variables in my GlobaAsa file, right?
>
>
> --
>
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
>
> "Sarmad Aljazrawi" <anonymous[shylme]@discussions.microsoft.com> escreveu

na
> mensagem news:eH9fe0F$(E-Mail Removed)...
> > Since you are redirecting then the easiest way is to send them as

> parameters
> > (Querystrings)
> >
> > response.redirect("Page2.aspx?m_lIdHrq="& m_Page2.m_lIdHrq

> &"&m_lNivelHrq="&
> > m_Page2.m_lNivelHrq &"&m_strFnc="& m_Page2.m_strFnc)
> >
> > or you can use Session variables.
> >
> > regards,
> > --
> > Sarmad Aljazrawi
> > B.Sc. Computer Science, MSDBA, MCP
> > www.aljazrawi.net
> >
> >
> > "ruca" <(E-Mail Removed)> wrote in message
> > news:OXzXtNF$(E-Mail Removed)...
> > > Hi,
> > > How can I pass the values of some variables from page1.aspx to

> page2.aspx?
> > > I try to define some variables in page2 and then when I click a button

> in
> > > page1 it will fill that variables (in page2) with values. The proble

is
> > that
> > > when I call page2 variable values are NULL.
> > >
> > > Like this:
> > >
> > > -------------------------------BEGIN
> > > CODE-----------------------------------------------
> > >
> > > Imports AppName.ClassNamePage2
> > >
> > > Dim m_Page2 as New ClassNamePage2
> > >
> > > Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e

> As
> > > System.EventArgs) Handles Button1.ServerClick
> > >
> > > //This values are in a DataSet and are correct (I debug them)
> > >
> > > m_Page2.m_lIdHrq =

CLng(ds.Tables("Dados").Rows(0).Item("IdLevel"))
> > > m_Page2.m_lNivelHrq =

CLng(ds.Tables("Dados").Rows(0).Item("Level"))
> > > m_Page2.m_strFnc = CStr(ds.Tables("Dados").Rows(0).Item("Name"))
> > >
> > > //this value it is given from a dropdownlist (I check it, and it

> > returns
> > > the right value)
> > > m_Page2.m_lIdFnc = CLng(UserName.SelectedItem.Value.ToString())
> > >
> > > Response.Redirect("Page2.aspx")
> > >
> > > //When opens page2.aspx the values are NULL
> > >
> > > End Sub
> > > -------------------------------END
> > > CODE-----------------------------------------------
> > >
> > > How can I solve this?
> > >
> > >
> > > --
> > >
> > > Thank's (if you try to help me)
> > > Hope this help you (if I try to help you)
> > > ruca
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Diferent VLANS but using same gateway BUZZ Cisco 1 04-18-2006 09:38 PM
Best practice for showing data from diferent queries in same form Corobori ASP .Net 5 05-07-2005 02:43 AM
Web form retains values over diferent stations =?Utf-8?B?Y0ZsZXVyeQ==?= ASP .Net 7 02-09-2005 04:17 PM
moving some classes into a diferent web application Glenn M ASP .Net 1 10-20-2004 12:25 PM
Pass variables value between diferent pages ruca ASP .Net Web Controls 4 02-26-2004 07:43 PM



Advertisments