您的位置:首页 > 其它

WSS3.0 WebPart 多语言支持的实现

2007-12-24 21:29 316 查看
WSS3.0支持两中类型的WebPart:

wss风格的WebPart - 从 Microsoft.SharePoint.WebPartPages.WebPart继承;

asp.net风格的WebPart - 从 System.Web.UI.WebControls.WebParts.WebPart继承;

对wss风格的webpart,采用系统提供的Microsoft.SharePoint.WebPartPages.ResourcesAttribute指定资源字符串key,然后

重载LoadResource方法处理资源文件的加载,示例如下:

[Guid("137b67b0-6155-40dc-bff0-4ab766c87e86")]

public class ResTestWP : Microsoft.SharePoint.WebPartPages.WebPart // System.Web.UI.WebControls.WebParts.WebPart

[Guid("137b67b0-6155-40dc-bff0-4ab766c87e86")]

public class ResTestWP : System.Web.UI.WebControls.WebParts.WebPart

class ResourceHelper

public class ResCategory : CategoryAttribute

public class ResWebDisplayName : WebDisplayNameAttribute

{

{ }

{

{

return ResourceHelper.GetResourceString(base.DisplayName);

}

}

}

通过以上的代码,可以实现WebPart编辑面板的多语言支持,webpart内部代码也可以通过ResourceHelper.GetResourceString获取资源字符串.

其他的Attribute类也可用上面的方法重新实现。

以上示例代码的命名不是很规范,ResCategory 应改成 ResCategoryAttribute.

ResWebDisplayName 应改成 ResWebDisplayNameAttribute. 编辑器不好用啊,就不改了~

下载代码:

/Files/jianyi0115/ResTestWP.rar
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐