zoukankan      html  css  js  c++  java
  • 让用户控件包装器“见鬼”去。

    把用户控件装载到到WebPart里面,在实际的项目中,我们有时候需要用很多用户控件在MOSS里面,如果用,用户控件包装器的话,客户一看就显示的很不专业,也影响公司的形象,所以,做项目的时候需要把用户控件包装成WebPart,这样就显示的稍微的好点咯。。。嘿嘿。
    其实也很简单,
    1。 步骤1写好自己的用户控件,然后,把他用户控件的页面放到
    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\WpLoadUc\AddUserControl.ascx下面
    然后把dll放到相应的moss bin 下面 或GAC
    2。写一个WebPart,很简单,代码如下:

    using System;
    using System.Runtime.InteropServices;
    using System.Web.UI;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Serialization;

    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using Microsoft.SharePoint.WebPartPages;

    namespace WPLoadUserControl
    {
        [Guid("0d2c817f-71c3-4349-b813-cf8eb81f4bd5")]
        public class WPLoadUserControl : System.Web.UI.WebControls.WebParts.WebPart
        {
            protected Control userControl;
            public WPLoadUserControl()
            {
                this.ExportMode = WebPartExportMode.All;
            }

            protected override void CreateChildControls()
            {
                //base.CreateChildControls();

                this.Controls.Clear();
                string userControlPath = @"/_controltemplates/WpLoadUc/AddUserControl.ascx";
                this.userControl = this.Page.LoadControl(userControlPath);
                this.Controls.Add(this.userControl);

            }
            protected override void Render(HtmlTextWriter writer)
            {
                // TODO: add custom rendering code here.
                 writer.Write("Show AA");
                 this.userControl.RenderControl(writer);

            }

        }
    }
    代码是不是很简单哦,WebPart 的部署就不用我说啦。。。
    3,然后修改下配置文件
    <SafeControl src="~/_controltemplates/WpLoadUc/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" />

    嘿嘿 指定到相应的用户控件哦。
    哈哈哈 ,各位是不是很简单,,嘿嘿快去测试哦。/
    。。。。。。。。。。。。。
    代码不是最好的,只是供大家参考。。

  • 相关阅读:
    Windows 8实例教程系列 开篇
    qt 开发发布于 windeploy.exe
    qt qoci 测试验证
    vmware vmx 版本不兼容
    qt oracle
    vc qt dll
    QOCIDriver unable to create environment
    qoci 编译完 放置位置 具体根据情况
    calling 'lastError' with incomplete return type 'QSqlError' qsqlquer
    Hbase 操作工具类
  • 原文地址:https://www.cnblogs.com/cxd4321/p/873131.html
Copyright © 2011-2022 走看看