zoukankan      html  css  js  c++  java
  • 我的第一个WebPart诞生

    安装SPS的过程非常顺利,这里就不说了!
    我来制作自己的第一个webpart!
    1.请先安装Web Part Templates for Visual Studio .NET 下载
    2.安装好以后,打开VS.NET 2003。在新增项目的对话框中找到Web Part Library,新增一个webPart,我取名[FlWebPart1],新生成的代码如下:
    t_webPart1.bmp点此看大图
    3.编译生成的FlWebPart1.dll就是我们的第一个WebPart。好了,按照网上的资料我作个如下改动:

     1protected override void CreateChildControls()
     2        {
     3             myUserControl =     this.Page.LoadControl("/bin/myWebPart1.ascx");
     4            base.CreateChildControls ();
     5        }

     6
     7        
     8        /// 
     9        /// Render this Web Part to the output parameter specified.
    10        /// 

    11        ///  The HTML writer to write out to 

    12        protected override void RenderWebPart(HtmlTextWriter output)
    13        {
    14            this.EnsureChildControls();
    15            output.Write(SPEncode.HtmlEncode(Text));
    16            if ( myUserControl != null )
    17            {
    18            myUserControl.RenderControl(output);
    19            }

    20        
    21        }

    4.在代码中你一定看到了一个"/bin/myWebPart1.ascx",这个其实就是一个传统的Web UserControl,跟它相关的.cs文件是webpart不需要的(ps:有几头牛上一这么说的)。怎么把UserControl跟.cs文件脱离呢:
       <%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> 

    <%@ Control Language="c#" AutoEventWireup="false" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <%@ Control Language="c#" AutoEventWireup="false"   TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    <%@ Control Language="c#" AutoEventWireup="false"   TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

    看去掉Codebehind, Inherits属性就可以了。
    5.在UserControl控件中拖入各种控件,我拖的是微软日历控件
    6.重新编译WebPart项目。

     

  • 相关阅读:
    Win下循环进入目录启动执行某任务
    Mysql数据库搭建-Windows
    Linux的服务器初始优化脚本。
    Linux下Find命令的使用
    一些判断Linux是否被黑的经验
    搭建docker私有仓库
    进程退出:SIGINT、SIGTERM和SIGKILL区别
    dockerfile使用
    k8s-ingress安装
    k8s-service
  • 原文地址:https://www.cnblogs.com/FlyFire/p/254882.html
Copyright © 2011-2022 走看看