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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

input type=button与asp:button的区别,以及runat=server的作用

發布時間:2024/3/13 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 input type=button与asp:button的区别,以及runat=server的作用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

<input type="button">與<asp:button>的區別,以及runat="server"的作用

在<input type="button">中只能編寫點擊事件onclick,并且只能在js中實現,那么如何讓<input type="button">像<asp:button>一樣可以在后臺實現呢

<input type="button" >添加runat="server" 并且添加onserverclick="Unnamed_ServerClick"點擊事件,并在后臺編寫它的點擊效果,這樣就會跟<asp:button>效果一樣

<input type="button">前臺代碼:

? ? ?<input type="button" name="name" value="確定" runat="server"(服務器控件的意思是在里頁面上建立了普通HTML標簽或ASP.NET服務器控件,他們需要在控件加上runat="server"來標記為服務器控件,ASP.NET就會解析進行一系列的處理,在后臺都可以調用通過標記的控件,獲取你需要對控件的一系列取值要求) onserverclick="Unnamed_ServerClick" />

? ? ?后臺代碼:

? ? ? protected void Unnamed_ServerClick(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? Response.Write("<script>alert('點擊有效果了!');</script>");
? ? ? ? }

<asp:button>前臺代碼:

? ? ?<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

? ? ? 后臺代碼:

? ? ??protected void Button1_Click(object sender, EventArgs e)
? ? ? ? {

? ? ? ? ? ?Response.Write("<script>alert('你好!');</script>");

? ? ? ? }

總結

以上是生活随笔為你收集整理的input type=button与asp:button的区别,以及runat=server的作用的全部內容,希望文章能夠幫你解決所遇到的問題。

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