Groups | Blog | Home
all groups > asp.net building controls > november 2004 >

asp.net building controls : maintain viewstate in listboxes


DC Gringo
11/6/2004 7:49:56 PM
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

Jos
11/7/2004 9:15:57 AM
[quoted text, click to view]

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
11/7/2004 1:57:25 PM
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



[quoted text, click to view]

DC Gringo
11/8/2004 1:51:44 PM
Anyone? A little help on this?

_____
DC G

[quoted text, click to view]

Alvin Bruney [MVP]
11/8/2004 5:22:31 PM
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
[quoted text, click to view]

DC Gringo
11/9/2004 9:40:39 AM
I'd be happy to, could I get a code sample?

_____
DC G

[quoted text, click to view]

AddThis Social Bookmark Button