日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

自定义ImageLinkButton美化提交按钮

發布時間:2024/4/14 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 自定义ImageLinkButton美化提交按钮 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

請訪問? http://www.aspx-office.cn 獲取更多資料

?

在提交中,最常用的是button,不過最近想在button前面顯示一張圖片,做起來很麻煩。

讓人你可以說使用ImageButton,但是ImageButton的ImageUrl的Image無法多次重用,使用style控制button的背景,在文本過長時,也難以控件,所以采用下面給出的一個解決方法

1建立ImageLinkButton

?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EControls.WebControls
{
??? [ToolboxData("<{0}:ImageLinkButton runat=server></{0}:ImageLinkButton>")]
??? public class ImageLinkButton : LinkButton
??? {
??????? [Bindable(true)]
??????? [Category("Appearance")]
??????? [DefaultValue("")]
??????? [Localizable(true)]
??????? [Description("要顯示的圖像的 Url。")]
??????? public string ImageUrl
??????? {
??????????? get
??????????? {
??????????????? String s = (String)ViewState["ImageUrl"];
??????????????? return ((s == null) ? String.Empty : s);
??????????? }

??????????? set
??????????? {
??????????????? ViewState["ImageUrl"] = value;
??????????? }
??????? }

??????? protected override void Render(HtmlTextWriter output)
??????? {
??????????? output.Write("<img src=""" + this.ResolveClientUrl(this.ImageUrl) + """/>");
??????????? base.Render(output);
??????? }
??? }
}

?

2在頁面里使用

?

?


正如你看到的,這里有一個ImageUrl屬性可以讓你設置圖片,下面是顯示效果

?


怎么樣還不錯吧

源代碼下載

?

ImageLinkButton.cs (1.03 kb)

轉載于:https://www.cnblogs.com/mqingqing123/archive/2009/01/19/1378241.html

總結

以上是生活随笔為你收集整理的自定义ImageLinkButton美化提交按钮的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。