maintain viewstate in listboxes

D

DC Gringo

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
 
J

Jos

DC said:
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 .
 
D

DC Gringo

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
 
D

DC Gringo

Anyone? A little help on this?

_____
DC G

DC Gringo said:
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
 
A

Alvin Bruney [MVP]

Can you put some javascript in the onload event to investigate what the
visibility property is at the time the page loads?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top