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项目。

     

  • 相关阅读:
    音视频入门-06-代码画图时间
    音视频入门-05-RGB-TO-BMP使用开源库
    音视频入门-04-BMP图像四字节对齐的问题
    音视频入门-03-RGB转成BMP图片
    控制input文本框只能输入正整数(H5)
    微信小程序自定义导航栏配置(顶部栏搜索框)
    React-日历组件(原生JS代码)
    package.json文件详解
    解决HTML5IOS拍照上传图片逆时针旋转90度问题(React)
    项目细节
  • 原文地址:https://www.cnblogs.com/FlyFire/p/254882.html
Copyright © 2011-2022 走看看