Disappearing Web Part Trick

Discussion in 'ASP .Net Web Controls' started by AL, Aug 21, 2006.

  1. AL

    AL Guest

    Hello, I'm pretty new to web part development. On playing around with this,
    pretty much for the first time, I noticed that when I ran the page and closed
    the web part, on subsequent runs of the page, the web part remains resolutely
    closed.

    I also noticed that resetting the controls ID property at design time, and
    re-running the page caused them to reappear. Is this normal behaviour for web
    parts or am I cracking up? Is there a more elegant way to get your part to
    reappear after inadvertantly closing it during testing?
    --
    Intrigued,

    Al
    AL, Aug 21, 2006
    #1
    1. Advertising

  2. Hi Al,

    I hear ya! I ran into that same issue when I was working on the Web part
    chapter of

    ASP.NET 2.0 All-In-One Desk Reference For Dummies
    http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471785989.html

    I added a button to the page and a little code to reset (ResetAllState) the
    state whenever I lost the parts. Here's the code from the book:

    <%@ Page Language="VB" %>
    <script runat="server">
    Protected Sub Button1_Click _
    (ByVal sender As Object, _
    ByVal e As System.EventArgs)
    Dim intCount As Integer
    intCount = _
    PersonalizationAdministration.ResetAllState _
    (PersonalizationScope.User)
    Response.Redirect("starterpart.aspx")
    End Sub
    </script>

    <html>
    <head runat="server">
    <title>Reset Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:button id="Button1" runat="server"
    onclick="Button1_Click" text="Reset" />
    </div>
    </form>
    </body>
    </html>

    Let us know if this helps?

    Ken
    Microsoft MVP [ASP.NET]


    "AL" <> wrote in message
    news:...
    > Hello, I'm pretty new to web part development. On playing around with
    > this,
    > pretty much for the first time, I noticed that when I ran the page and
    > closed
    > the web part, on subsequent runs of the page, the web part remains
    > resolutely
    > closed.
    >
    > I also noticed that resetting the controls ID property at design time, and
    > re-running the page caused them to reappear. Is this normal behaviour for
    > web
    > parts or am I cracking up? Is there a more elegant way to get your part
    > to
    > reappear after inadvertantly closing it during testing?
    > --
    > Intrigued,
    >
    > Al
    Ken Cox [Microsoft MVP], Aug 22, 2006
    #2
    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. Tim Mackey
    Replies:
    0
    Views:
    300
    Tim Mackey
    Jul 27, 2004
  2. Mike
    Replies:
    0
    Views:
    448
  3. asianavatar

    Disappearing web controls

    asianavatar, Jun 27, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    106
    asianavatar
    Jun 27, 2005
  4. Peter Cook

    Web Service with disappearing Web Methods

    Peter Cook, Sep 12, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    105
    Peter Cook
    Sep 12, 2005
  5. Jack
    Replies:
    8
    Views:
    274
Loading...

Share This Page