如何个性化网页部件? [英] How to personalize web part?

查看:76
本文介绍了如何个性化网页部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



目前,我正在处理Web部件,对此我几乎没有疑问.我正在使用没有asp.net成员资格提供程序的表单身份验证.

如何在应用程序中配置个性化? 我已经在我的web.config中设置了以下settigs:

Hi,

Currently I am working with web parts, I have few questions regarding it. I am using forms authentication without asp.net membership provider.

How to configure personalization in applization? I have set bellow settigs in my web.config:

<webParts>
      <personalization defaultProvider="PersonalizationProvider">
        <providers>
          <add name="PersonalizationProvider"

               type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

                connectionStringName="personalizationConnectionString"

               />
        </providers>
        <authorization>
          <allow users="*" verbs="enterSharedScope"/>
        </authorization>
      </personalization>
    </webParts>




并如下所示为PersonalizationProvider创建了一个类:




And created one class for PersonalizationProvider as shown bellow:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for clsPersonalization
/// </summary>
public class PersonalizationProvider: SqlPersonalizationProvider,IPersonalizable
{
    public PersonalizationProvider()
    {
        //
        // TODO: Add constructor logic here
        //

    }
    public override void SavePersonalizationState(PersonalizationState state)
    {
        base.SavePersonalizationState(state);
    }
    protected override void ResetPersonalizationBlob(WebPartManager webPartManager, string path, string userName)
    {
        base.ResetPersonalizationBlob(webPartManager, path, userName);
    }
    public override void Initialize(string name, System.Collections.Specialized.NameValueCollection configSettings)
    {
        base.Initialize(name, configSettings);
    }
    public override void ResetPersonalizationState(WebPartManager webPartManager)
    {
        base.ResetPersonalizationState(webPartManager);
    }
    protected override void LoadPersonalizationBlobs(WebPartManager webPartManager, string path, string userName, ref byte[] sharedDataBlob, ref byte[] userDataBlob)
    {
        base.LoadPersonalizationBlobs(webPartManager, path, userName, ref sharedDataBlob, ref userDataBlob);
    }
    protected override void SavePersonalizationBlob(WebPartManager webPartManager, string path, string userName, byte[] dataBlob)
    {
        base.SavePersonalizationBlob(webPartManager, path, userName, dataBlob);
    }

    #region IPersonalizable Members

    public bool IsDirty
    {
        get { throw new NotImplementedException(); }
    }

    public void Load(PersonalizationDictionary state)
    {
        throw new NotImplementedException();
    }

    public void Save(PersonalizationDictionary state)
    {
        throw new NotImplementedException();
    }

    #endregion
}



现在如何个性化我的Web部件?请给我建议.

预先感谢,
Naresh Goradara



Now how to personalize my web parts? Please suggest me.

Thanks in advance,
Naresh Goradara

推荐答案



我希望这还不算太晚.而且我想您有两种选择:

1.使用默认的.net SqlPersonalizationProvider(需要ms sql服务器).如果您正确使用表单身份验证,则在没有默认成员资格提供程序的情况下也可以使用.可以找到配置
在每个Webpart教程中(另请参见下面的链接).

2.如果您不使用sql server或想以其他方式使用个性化设置,则可以实现自己的个性化设置提供程序.
我已经为postgres写了一篇文章,并查看了 FileBasedPersonalizationProvider 来使我入门(只需将整个基于文件的内容替换为
数据库读/写操作).本教程很好地描述了整个过程.没什么大不了的,因为基本上所有有关使用/更新单个blob字段的问题.

请注意Firefox中Webpart的拖放问题.它不适用于当前版本的webpartmanager,但是有一个较旧的预览"版本,该版本为Firefox提供了拖放功能.如果遇到这些问题,您将了解我的意思.我花了一段时间才弄清楚拖放不起作用不是我的错. (一会儿我的意思是小时数=()

希望对您有帮助
Hi,

i hope this isn''t way too late..and i guess you have two choices:

1. Use the default .net SqlPersonalizationProvider (which requires ms sql server). This also works without the default membership provider if you use forms authentication correctly. The configuration can be found
in every webpart tutorial (see link below also).

2. If you dont use sql server or want to use the personalization differently, you can implement your own personalizationprovider.
I''ve written one for postgres and had a look at the FileBasedPersonalizationProvider to get me started (just replace the whole file-based-stuff by
database reading/writing operations). This tutorial describes the whole process pretty well. It''s not a big deal as it is basically all about using/updating a single blob field.

Be aware of a drag/drop issue with webparts in firefox. It doesnt work with the current version of the webpartmanager, but there''s an older "preview" version which provides drag/drop features for firefox. If you encounter these problems, you''ll know what i mean=). I took me a while to figure out that it wasnt my fault that drag/drop didnt work. (by a while i mean hours =( )

Hope this helps


这篇关于如何个性化网页部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆