国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

創建一個基本webpart

2024-07-21 02:23:27
字體:
來源:轉載
供稿:網友
按照sps sdk的文檔,我試著自己開發webpart,過程是這樣的:

1、使用webpart模板創建一個工程

2、定義輸出路徑到interput/wwwroot/bin下。

3、設置版本號(每個.net程序都要做的)

4、準備好強名稱所需的密鑰,我給自己弄了一個zhouyikey.snk,放在c盤根目錄下,所有的程序都要用它。

5、接下來就開始編輯代碼了,首先檢查自己所需的namespace是否都已經引用了

6、定義toolbox data,如:

[toolboxdata("<{0}:simplewebpart runat=server></{0}:simplewebpart>")]

7、定義xml namespace

[xmlroot(namespace="mywebparts")]

我不知道所有的webpart都用默認的可不可以,但是,從文檔來看,好像不太合適,因為xmlroot這種方式使用全局的定義,我擔心如果都使用默認的是不是就會有沖突。,所以,最好跟工程的namespace一直為好。



8、然后,就可以在renderwebpart方法中寫自己要顯示的東西了。



9、如果,你要在你的webpart上創建一些控件,你必須在renderwebpart中調用“renderchildren(output);”,下面是創建控件的程序:

htmlbutton _mybutton;

htmlinputtext _mytextbox;

// event handler for _mybutton control that sets the

// title property to the value in _mytextbox control.

public void _mybutton_click (object sender, eventargs e)

{

this.title = _mytextbox.value;

try

{

this.saveproperties=true;

}

catch

{

caption = "error... could not save property.";

}

}

// override the asp.net web.ui.controls.createchildcontrols

// method to create the objects for the web part's controls.

protected override void createchildcontrols ()

{

// create _mytextbox control.

_mytextbox = new htmlinputtext();

_mytextbox.value="";

controls.add(_mytextbox);

// create _mybutton control and wire its event handler.

_mybutton = new htmlbutton();

_mybutton.innertext = "set web part title";

_mybutton.serverclick += new eventhandler (_mybutton_click);

controls.add (_mybutton);

}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阳城县| 定远县| 勃利县| 赤水市| 乌拉特中旗| 邵东县| 溧阳市| 桃江县| 柘荣县| 辽源市| 英山县| 伊春市| 泗洪县| 安福县| 岑溪市| 垣曲县| 射阳县| 南平市| 油尖旺区| 连江县| 南召县| 江北区| 襄城县| 稷山县| 东丰县| 霍山县| 雷波县| 磴口县| 商城县| 沈丘县| 开封县| 武隆县| 区。| 呼和浩特市| 尼玛县| 新宁县| 镇坪县| 卢湾区| 临邑县| 建水县| 灵寿县|