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

Discussion in 'ASP .Net' started by ujjc001, Jul 27, 2005.

  1. ujjc001

    ujjc001 Guest

    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.
     
    ujjc001, Jul 27, 2005
    #1
    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. Sundaresan
    Replies:
    1
    Views:
    327
    Natty Gur
    Nov 23, 2003
  2. Flare
    Replies:
    5
    Views:
    550
    Flare
    Nov 21, 2003
  3. Brett
    Replies:
    1
    Views:
    488
    Brett
    Sep 9, 2004
  4. j-in-uk
    Replies:
    1
    Views:
    325
    Muhammad Naveed Yaseen
    Mar 30, 2007
  5. Travis
    Replies:
    3
    Views:
    362
Loading...

Share This Page