Link to home
Start Free TrialLog in
Avatar of Brian
BrianFlag for United States of America

asked on

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>
Avatar of sasapopovic
sasapopovic
Flag of Serbia image

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
Avatar of Brian

ASKER

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>
 
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
Avatar of Brian

ASKER

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>
ASKER CERTIFIED SOLUTION
Avatar of sasapopovic
sasapopovic
Flag of Serbia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brian

ASKER

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?
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
Avatar of Brian

ASKER

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

Avatar of Brian

ASKER

Thanks for all your help.