Pass variables value between diferent pages

Discussion in 'ASP .Net Web Controls' started by ruca, Feb 26, 2004.

  1. ruca

    ruca Guest

    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
     
    ruca, Feb 26, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:OXzXtNF$...
    > 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
    >
    >
     
    Sarmad Aljazrawi, Feb 26, 2004
    #2
    1. Advertising

  3. ruca

    ruca Guest

    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$...
    > 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" <> wrote in message
    > news:OXzXtNF$...
    > > 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
    > >
    > >

    >
    >
     
    ruca, Feb 26, 2004
    #3
  4. ruca

    EricJ Guest

    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" <> wrote in message
    news:O9ycx6F$...
    > 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$...
    > > 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" <> wrote in message
    > > news:OXzXtNF$...
    > > > 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
    > > >
    > > >

    > >
    > >

    >
    >
     
    EricJ, Feb 26, 2004
    #4
  5. 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" <> wrote in message
    news:O9ycx6F$...
    > 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$...
    > > 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" <> wrote in message
    > > news:OXzXtNF$...
    > > > 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
    > > >
    > > >

    > >
    > >

    >
    >
     
    Sarmad Aljazrawi, Feb 26, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ruca
    Replies:
    4
    Views:
    448
    Sarmad Aljazrawi
    Feb 26, 2004
  2. Glenn M
    Replies:
    1
    Views:
    329
    Eliyahu Goldin
    Oct 20, 2004
  3. =?Utf-8?B?Y0ZsZXVyeQ==?=

    Web form retains values over diferent stations

    =?Utf-8?B?Y0ZsZXVyeQ==?=, Feb 8, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    343
    Patrice
    Feb 9, 2005
  4. Corobori
    Replies:
    5
    Views:
    352
    Corobori
    May 7, 2005
  5. Replies:
    1
    Views:
    240
    Dennis Lee Bieber
    Jun 9, 2005
Loading...

Share This Page