ASP.NET: WebPart Close and Minimize Links

I have a WebPart (code is below) that works fine with retrieving my data from DB, but it does not display the Minimize and Close links.

<%@ Page Language="VB" %>
<%@ register src="App_Data/databind.ascx" tagname="displaymodevb" tagprefix="uc2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form2" runat="server">
    <div>
         
<asp:WebPartManager ID="WebPartManager2" runat="server" />

        <asp:WebPartZone ID="WebPartZone2" runat="server">
           
           <ZoneTemplate>  
                        <uc2:displaymodevb id="grid9" runat="server" title="First Web Part" width="500" />        
        </ZoneTemplate>

        </asp:WebPartZone>  
       
    </div>
    </form>
</body>
</html>
LVL 4
asp_net2Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sasapopovicConnect With a Mentor Commented:
You can solve it like this:

Add:
<authentication mode="Windows" />
to your Web.config.

Then go to a page in your web site, log-in and then try to access your page with web part.
NB: you can set authentication to "Forms" also if you want it to be accessible from internet users. But you can not bring a user to "edit" mode on web parts page if he/she is not authenticated.

Regards,
Sasa
0
 
sasapopovicCommented:
It looks like you are looking the page as anonymus user (not authenticated).

You can try next:
1. Open IIS management console
2. Go to your web site and then to virtual directory for the application hosting your web page with web part
3. Right click on virtual directory and select "Options"
4. Go to "Directory Security" tab and click on "Edit..."
5. Deselect "Allow anonymus..."
6. Select "Integrated Windows Authentication"

Run your project again and check if there are minimize and close options. The thing is that personalization works only for authenticated users.

Cheers,
Sasa
0
 
asp_net2Author Commented:
That did not work. Also this application must be viewable to anyone outside the network. See the error message below.

The specified display mode is currently disabled on this page. Make sure personalization is enabled for the current user.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The specified display mode is currently disabled on this page. Make sure personalization is enabled for the current user.
Parameter name: value

Source Error:

Line 9:  <script runat="server">
Line 10:     Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Line 11:         WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode
Line 12:     End Sub
Line 13: </script>
 
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
sasapopovicCommented:
You are getting that error message because you probably didn't setup authentication mechanism. When you give your users rights to personalize their account (by minimizing certain web parts for example) then they need to be authenticated.

Check answers on this post: http://geekswithblogs.net/chrishan/archive/2005/07/20/47799.aspx

Regards,
Sasa
0
 
asp_net2Author Commented:
sasapopovic,

I still have no idea. Please see below of what I added from the link you provided me. Now when I add this code it does not authenticate.

WEB.CONFIG:

    <add name="SQLConnString" connectionString="Data Source=TEST;Initial Catalog=aspnetdb;User ID=sa;Password=test1234" providerName="System.Data.SqlClient" />


<webParts>
      <personalization
         defaultProvider="SqlPersonalizationProvider">
        <providers>
          <add name="SqlPersonalizationProvider" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider" connectionStringName="PSSA" applicationName="/" />
        </providers>
        <authorization>
          <deny users="*" verbs="enterSharedScope" />
          <allow users="*" verbs="modifyState" />
        </authorization>
      </personalization>
    </webParts>
0
 
asp_net2Author Commented:
sasapopovic,

That worked. I just have a few questions before closing.

1.) How can I also include authentication = forms within the same web.config file? I have a login form that I created manually for a few pages that authenticate the user from an SQL DB.

2.) What else do I need to add to enable my application to use the aspnet DB that comes with ASP.NET 2 for membership and roles.

3.) Do I even need this aspnet DB to use web parts? Or can I go without it if I'm not worried about authenticating people?
0
 
sasapopovicCommented:
Hm, those are 3 new questions :-)

1.) Just change <authentication mode="Windows" />  into <authentication mode="Forms" /> You can check next article on how to use and configure forms authentication: http://msdn2.microsoft.com/en-us/library/ms998317.aspx
2.) First of all, you don't need to use Membership and Role providers with Forms authentication but you can do that. It is not that trivial thing so I suggest you first read about it a litle. This may help: http://aspnet.4guysfromrolla.com/articles/120705-1.aspx
3.) You don't need the aspnet DB but you need to have an authentication mechanism. So you can authenticate users using Windows authetnication but then you need to have all users of you web site registered in windows (or ActiveDirectory), using Forms authentication (with aspnet DB and Membership provider) or with some other authentication mechanism.

I hope these answers are enough for successfuly closing of this question ;-)

If you have questions related to forms authentication, membership and role providers or something similar then I suggest you open a new question(s).

Regards,
Sasa
0
 
asp_net2Author Commented:
sasapopovic,

Thanks again. One more question I forgot to add. I promise :) I will definetly close after this.

1.) When I run my page all is well but what determines the application for remembering when i minimize a webpart. For example I ran the webpart page and minimized the webpart and then closed the browser. When i ran the webpart page again the webpart was still minimized. What causes this to remember my selection?
0
 
sasapopovicCommented:
The personalization feature that is part of portal framework.
There is a plenty of articles about that on web. Here are some of them:
http://msdn.microsoft.com/msdnmag/issues/04/06/aspnet20portals/default.aspx
http://msdn.microsoft.com/msdnmag/issues/05/09/WebParts/default.aspx

Regards,
Sasa

0
 
asp_net2Author Commented:
Thanks for all your help.
0
All Courses

From novice to tech pro — start learning today.