maintain viewstate in listboxes

Discussion in 'ASP .Net' started by DC Gringo, Nov 7, 2004.

  1. DC Gringo

    DC Gringo Guest

    I have an asp.net vb page with two web user controls on it. The first user
    control, uc1.ascx has a series of list boxes that are populated in series by
    each other with ONSELECTEDINDEXCHANGED.

    In the second control, uc2.ascx, lower down on the page, there is an
    imagebutton. When the imagebutton is clicked, it goes to the same page with
    a change in url parameter pageID. The control mentioned above sticks
    around, while the second one is swapped out for another web user control,
    uc3.ascx.

    The values populated and selections in the listbox in the uc1.ascx are
    getting lost despite viewstate being enabled as true.

    What is going on?

    The imagebutton looks like this:

    Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e As
    System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    Response.Redirect("~/advanced/default.aspx?pageID=shas")
    End Sub


    --
    _____
    DC G
    DC Gringo, Nov 7, 2004
    #1
    1. Advertising

  2. DC Gringo

    Jos Guest

    DC Gringo wrote:
    > I have an asp.net vb page with two web user controls on it. The
    > first user control, uc1.ascx has a series of list boxes that are
    > populated in series by each other with ONSELECTEDINDEXCHANGED.
    >
    > In the second control, uc2.ascx, lower down on the page, there is an
    > imagebutton. When the imagebutton is clicked, it goes to the same
    > page with a change in url parameter pageID. The control mentioned
    > above sticks around, while the second one is swapped out for another
    > web user control, uc3.ascx.
    >
    > The values populated and selections in the listbox in the uc1.ascx are
    > getting lost despite viewstate being enabled as true.
    >
    > What is going on?
    >
    > The imagebutton looks like this:
    >
    > Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e As
    > System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    > Response.Redirect("~/advanced/default.aspx?pageID=shas")
    > End Sub


    Using Response.Redirect causes all viewstate to be lost.
    With Redirect, you call the page as if it is the first time.

    I suggest you omit the Response.Redirect, and do the swapping in
    imgShasTab_Click .

    --

    Jos
    Jos, Nov 7, 2004
    #2
    1. Advertising

  3. DC Gringo

    DC Gringo Guest

    Well that certainly makes sense.

    Ok, so I tried:

    Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e As
    System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click

    shas1.Visible = True
    Me.Visible = False

    End Sub

    This Sub imgShasTab_Click is in the same control as the imagebutton control.
    The result is that the Me.Visible = False part works, but the shas1.visible
    part does not.

    What am I doing wrong?

    _____
    DC G



    "Jos" <> wrote in message
    news:u$...
    > DC Gringo wrote:
    > > I have an asp.net vb page with two web user controls on it. The
    > > first user control, uc1.ascx has a series of list boxes that are
    > > populated in series by each other with ONSELECTEDINDEXCHANGED.
    > >
    > > In the second control, uc2.ascx, lower down on the page, there is an
    > > imagebutton. When the imagebutton is clicked, it goes to the same
    > > page with a change in url parameter pageID. The control mentioned
    > > above sticks around, while the second one is swapped out for another
    > > web user control, uc3.ascx.
    > >
    > > The values populated and selections in the listbox in the uc1.ascx are
    > > getting lost despite viewstate being enabled as true.
    > >
    > > What is going on?
    > >
    > > The imagebutton looks like this:
    > >
    > > Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e As
    > > System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    > > Response.Redirect("~/advanced/default.aspx?pageID=shas")
    > > End Sub

    >
    > Using Response.Redirect causes all viewstate to be lost.
    > With Redirect, you call the page as if it is the first time.
    >
    > I suggest you omit the Response.Redirect, and do the swapping in
    > imgShasTab_Click .
    >
    > --
    >
    > Jos
    >
    >
    DC Gringo, Nov 7, 2004
    #3
  4. DC Gringo

    DC Gringo Guest

    Anyone? A little help on this?

    _____
    DC G

    "DC Gringo" <> wrote in message
    news:...
    > Well that certainly makes sense.
    >
    > Ok, so I tried:
    >
    > Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e As
    > System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    >
    > shas1.Visible = True
    > Me.Visible = False
    >
    > End Sub
    >
    > This Sub imgShasTab_Click is in the same control as the imagebutton

    control.
    > The result is that the Me.Visible = False part works, but the

    shas1.visible
    > part does not.
    >
    > What am I doing wrong?
    >
    > _____
    > DC G
    >
    >
    >
    > "Jos" <> wrote in message
    > news:u$...
    > > DC Gringo wrote:
    > > > I have an asp.net vb page with two web user controls on it. The
    > > > first user control, uc1.ascx has a series of list boxes that are
    > > > populated in series by each other with ONSELECTEDINDEXCHANGED.
    > > >
    > > > In the second control, uc2.ascx, lower down on the page, there is an
    > > > imagebutton. When the imagebutton is clicked, it goes to the same
    > > > page with a change in url parameter pageID. The control mentioned
    > > > above sticks around, while the second one is swapped out for another
    > > > web user control, uc3.ascx.
    > > >
    > > > The values populated and selections in the listbox in the uc1.ascx are
    > > > getting lost despite viewstate being enabled as true.
    > > >
    > > > What is going on?
    > > >
    > > > The imagebutton looks like this:
    > > >
    > > > Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e As
    > > > System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    > > > Response.Redirect("~/advanced/default.aspx?pageID=shas")
    > > > End Sub

    > >
    > > Using Response.Redirect causes all viewstate to be lost.
    > > With Redirect, you call the page as if it is the first time.
    > >
    > > I suggest you omit the Response.Redirect, and do the swapping in
    > > imgShasTab_Click .
    > >
    > > --
    > >
    > > Jos
    > >
    > >

    >
    >
    DC Gringo, Nov 8, 2004
    #4
  5. Can you put some javascript in the onload event to investigate what the
    visibility property is at the time the page loads?

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    Got tidbits? Get it here... http://tinyurl.com/27cok
    "DC Gringo" <> wrote in message
    news:eaL$...
    > Anyone? A little help on this?
    >
    > _____
    > DC G
    >
    > "DC Gringo" <> wrote in message
    > news:...
    >> Well that certainly makes sense.
    >>
    >> Ok, so I tried:
    >>
    >> Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e As
    >> System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    >>
    >> shas1.Visible = True
    >> Me.Visible = False
    >>
    >> End Sub
    >>
    >> This Sub imgShasTab_Click is in the same control as the imagebutton

    > control.
    >> The result is that the Me.Visible = False part works, but the

    > shas1.visible
    >> part does not.
    >>
    >> What am I doing wrong?
    >>
    >> _____
    >> DC G
    >>
    >>
    >>
    >> "Jos" <> wrote in message
    >> news:u$...
    >> > DC Gringo wrote:
    >> > > I have an asp.net vb page with two web user controls on it. The
    >> > > first user control, uc1.ascx has a series of list boxes that are
    >> > > populated in series by each other with ONSELECTEDINDEXCHANGED.
    >> > >
    >> > > In the second control, uc2.ascx, lower down on the page, there is an
    >> > > imagebutton. When the imagebutton is clicked, it goes to the same
    >> > > page with a change in url parameter pageID. The control mentioned
    >> > > above sticks around, while the second one is swapped out for another
    >> > > web user control, uc3.ascx.
    >> > >
    >> > > The values populated and selections in the listbox in the uc1.ascx
    >> > > are
    >> > > getting lost despite viewstate being enabled as true.
    >> > >
    >> > > What is going on?
    >> > >
    >> > > The imagebutton looks like this:
    >> > >
    >> > > Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e
    >> > > As
    >> > > System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    >> > > Response.Redirect("~/advanced/default.aspx?pageID=shas")
    >> > > End Sub
    >> >
    >> > Using Response.Redirect causes all viewstate to be lost.
    >> > With Redirect, you call the page as if it is the first time.
    >> >
    >> > I suggest you omit the Response.Redirect, and do the swapping in
    >> > imgShasTab_Click .
    >> >
    >> > --
    >> >
    >> > Jos
    >> >
    >> >

    >>
    >>

    >
    >
    Alvin Bruney [MVP], Nov 8, 2004
    #5
  6. DC Gringo

    DC Gringo Guest

    I'd be happy to, could I get a code sample?

    _____
    DC G

    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:...
    > Can you put some javascript in the onload event to investigate what the
    > visibility property is at the time the page loads?
    >
    > --
    > Regards,
    > Alvin Bruney
    > [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    > Got tidbits? Get it here... http://tinyurl.com/27cok
    > "DC Gringo" <> wrote in message
    > news:eaL$...
    > > Anyone? A little help on this?
    > >
    > > _____
    > > DC G
    > >
    > > "DC Gringo" <> wrote in message
    > > news:...
    > >> Well that certainly makes sense.
    > >>
    > >> Ok, so I tried:
    > >>
    > >> Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e As
    > >> System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    > >>
    > >> shas1.Visible = True
    > >> Me.Visible = False
    > >>
    > >> End Sub
    > >>
    > >> This Sub imgShasTab_Click is in the same control as the imagebutton

    > > control.
    > >> The result is that the Me.Visible = False part works, but the

    > > shas1.visible
    > >> part does not.
    > >>
    > >> What am I doing wrong?
    > >>
    > >> _____
    > >> DC G
    > >>
    > >>
    > >>
    > >> "Jos" <> wrote in message
    > >> news:u$...
    > >> > DC Gringo wrote:
    > >> > > I have an asp.net vb page with two web user controls on it. The
    > >> > > first user control, uc1.ascx has a series of list boxes that are
    > >> > > populated in series by each other with ONSELECTEDINDEXCHANGED.
    > >> > >
    > >> > > In the second control, uc2.ascx, lower down on the page, there is

    an
    > >> > > imagebutton. When the imagebutton is clicked, it goes to the same
    > >> > > page with a change in url parameter pageID. The control mentioned
    > >> > > above sticks around, while the second one is swapped out for

    another
    > >> > > web user control, uc3.ascx.
    > >> > >
    > >> > > The values populated and selections in the listbox in the uc1.ascx
    > >> > > are
    > >> > > getting lost despite viewstate being enabled as true.
    > >> > >
    > >> > > What is going on?
    > >> > >
    > >> > > The imagebutton looks like this:
    > >> > >
    > >> > > Private Sub imgShasTab_Click(ByVal sender As System.Object, ByVal e
    > >> > > As
    > >> > > System.Web.UI.ImageClickEventArgs) Handles imgShasTab.Click
    > >> > > Response.Redirect("~/advanced/default.aspx?pageID=shas")
    > >> > > End Sub
    > >> >
    > >> > Using Response.Redirect causes all viewstate to be lost.
    > >> > With Redirect, you call the page as if it is the first time.
    > >> >
    > >> > I suggest you omit the Response.Redirect, and do the swapping in
    > >> > imgShasTab_Click .
    > >> >
    > >> > --
    > >> >
    > >> > Jos
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
    DC Gringo, Nov 9, 2004
    #6
    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. John Saunders
    Replies:
    0
    Views:
    702
    John Saunders
    Aug 29, 2003
  2. John Timney \(Microsoft MVP\)

    Re: Listbox filled with Javascript does NOT maintain viewstate

    John Timney \(Microsoft MVP\), Aug 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    561
    John Timney \(Microsoft MVP\)
    Aug 29, 2003
  3. Luis Esteban Valencia

    ASP.NET, Listboxes, Javascript and the Viewstate

    Luis Esteban Valencia, Jan 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    736
    Luis Esteban Valencia
    Jan 17, 2005
  4. DC Gringo

    maintain viewstate in listboxes

    DC Gringo, Nov 7, 2004, in forum: ASP .Net Building Controls
    Replies:
    5
    Views:
    156
    DC Gringo
    Nov 9, 2004
  5. DC Gringo

    maintain viewstate in listboxes

    DC Gringo, Nov 7, 2004, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    125
    DC Gringo
    Nov 9, 2004
Loading...

Share This Page