請參考:建置動作(檔案屬性)
1: using System;2: using System.Collections.Generic;3: using System.ComponentModel;4: using System.Linq;5: using System.Text;6: using System.Web;7: using System.Web.UI;8: using System.Web.UI.WebControls;9: using System.Web.UI.WebControls.WebParts;10:11: [assembly: WebResource("WebPartLibrary.Images.refresh.gif", "image/gif")]12:13: namespace WebPartLibrary14: {15: public class VerbWebPart : WebPart16: {17: public override WebPartVerbCollection Verbs18: {19: get20: {21: string imgUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "WebPartLibrary.Images.refresh.gif");22:23: List<WebPartVerb> menu = new List<WebPartVerb>();24: WebPartVerb menuItem = new WebPartVerb("Refresh",25: RefreshTest,26: "return confirm('Sure you send?')");27: menuItem.Text = "Refresh";28: menuItem.Description = "Refresh the data";29: menuItem.ImageUrl = imgUrl;30: menu.Add(menuItem);31:32: return new WebPartVerbCollection(menu);33: //return base.Verbs;34: }35: }36:37: void RefreshTest(object sender, WebPartEventArgs e){38: }39:40: private string _title = "This is a test part";41: [Personalizable(true)]42: [WebBrowsable(true)]43: [WebDisplayName("Title")]44: public override string Title45: {46: get { return _title; }47: set { _title = value;}48: }49:50: protected override void RenderContents(HtmlTextWriter output)51: {52: output.Write("Hello World!!");53: }54: }55: }
產生的Code
<a onclick="return confirm('Sure you send?');"title="Refresh the data"href="javascript:__doPostBack('ctl00$MainContent$WebPartZone1','partverb:Refresh:VerbWebPart1')"><img title="Refresh the data"src="/WebResource.axd?d=b0mWHY8S-KhFmq2i0Ng64vjCr7jtn6d1PqDQASYhlciLFSkUesn25v94jo0Hl8v3SSeikIor9zVbWy0TKuelog2&t=634156163432539640"alt="Refresh"></a>
沒有留言:
張貼留言