Loading usercontrols, viewstate problem, slighly different from all others "viewstate uc problems" p

U

ujjc001

Here's the layout. Aspx has a repeater on the left, which will call a
function to change a session var that holds the usercontrol name to add
(i.e. "uc_myusercontrol.ascx") and then calls default.aspx which in
page init, loads the control.

The problem is that if the user clicks on a link, the page starts to
reload but the user clicks on another link prior to the page completing
the load the viewstate error happens. Here's some relevant code below.

----Aspx
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
InitializeComponent()
loadUC(Session.Contents("CurrentUC"))
End Sub

Public Sub loadUC(ByVal contname As String)
ph_MainForm.Controls.Clear()
Dim mainuc As New System.Web.UI.Control
mainuc = LoadControl("usercontrols\" & contname)
mainuc.ID = Left(contname, (Len(contname) - 5))
ph_MainForm.Controls.Add(mainuc)
Session.Contents("LoadedUC") = contname
End Sub

---And called from any page to reload---
Public Shared Function setpage(ByVal newpage As String)
HttpContext.Current.Session.Contents("CurrentUC") = newpage
HttpContext.Current.Response.Redirect("default.aspx")
End Function

I've tried setting enableviewstate = false on the PH but then nothing
in the app works (data binding and such) after postback.
Really need to figure out a way to stop the "setpage" from happening
until the page is fully loaded. Any ideas would be GREATLY Appreciated.
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top