隐藏自定义可视化Web部件的默认属性 [英] Hiding default properties for a custom visual web part

查看:377
本文介绍了隐藏自定义可视化Web部件的默认属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法隐藏Web部件的常用属性?例如布局或外观部分。



我创建了一个新的视觉Web部件,我不能为管理员编辑它很容易,在编辑Web部件时需要标准布局/外观设置



任何想法如何在编辑面板中隐藏基本属性?

解决方案

这里有一种方法来实现这一点。在您的编辑器部分中,将其他EditorParts的容器标记为不可见:

  class EditorPartTest:EditorPart 
{
protected override void CreateChildControls()
{
Parent.Controls [1] .Visible = false;
Parent.Controls [2] .Visible = false;
base.CreateChildControls();
}

public override bool ApplyChanges()
{
return true;
}

public override void SyncChanges()
{
}
}

并使用它从你的Web部件,如下:

  public class VisualWebPart1 :WebPart 
{
public override EditorPartCollection CreateEditorParts()
{
ArrayList partsArray = new ArrayList();

EditorPartTest editor = new EditorPartTest();
editor.ID = this.ID +_editorPart;
partsArray.Add(editor);

return new EditorPartCollection(partsArray);
}
}

然后你应该得到这样的结果: p>

http://joelblogs.co.uk/? attachment_id = 10785



希望这有助于!



joel



joelblogs.co.uk



SharePoint Architect博客


Is there a way of hiding Common properties of Web Parts? The Layout or appearance section for example.

I have created a new visual web part and I wan't to make it very easy to edit for the administrators and they don't need the standard layout / appearance settings when they go to 'edit web part'

Any ideas how to hide the base properties from the edit panel? Been searching all over but can't see anything in the documentation.

解决方案

Here's one way to achieve this. In your EditorPart, mark the container of the other EditorParts as not Visible:

class EditorPartTest : EditorPart
{
    protected override void CreateChildControls()
    {
        Parent.Controls[1].Visible = false;
        Parent.Controls[2].Visible = false;
        base.CreateChildControls();
    }

    public override bool ApplyChanges()
    {
        return true;
    }

    public override void SyncChanges()
    {
    }
}

And use it from your web part like this:

public class VisualWebPart1 : WebPart
{
    public override EditorPartCollection CreateEditorParts()
    {
        ArrayList partsArray = new ArrayList();

        EditorPartTest editor = new EditorPartTest();
        editor.ID = this.ID + "_editorPart";
        partsArray.Add(editor);

        return new EditorPartCollection(partsArray);
    }
}

Then you should get a result like this:

http://joelblogs.co.uk/?attachment_id=10785

Hope this helps!

joel

joelblogs.co.uk

SharePoint Architect Blog

这篇关于隐藏自定义可视化Web部件的默认属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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