Disappearing Web Part Trick

A

AL

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?
 
K

Ken Cox [Microsoft MVP]

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]
 

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,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top