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

     

  • 相关阅读:
    iOS Provisioning Profile(Certificate)与Code Signing详解
    FW 常见的性能测试工具有: loadRunner/netperf/httperf/apache_ab/Apache JMeter
    android Instrumentation 转载
    FW 编译Android系统源码和内核源码
    FW 每秒百万级别的 HTTP 请求 sung: 重型的(heavy-duty)、分布式的、多协议测试工具
    Docker Hub Mirror
    MinGW安装和使用
    jdk,maven,tomcat 的环境配置
    错误400-The request sent by the client was syntactically incorrect
    pom.xml
  • 原文地址:https://www.cnblogs.com/FlyFire/p/254882.html
Copyright © 2011-2022 走看看