<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Attribute.aspx.vb" Inherits="Attribute" %> <html> <head> <title>ThaiCreate.Com ASP.NET - Attribute</title> </head> <body> <form id="form1" runat="server"> <script language="JavaScript"> function fncTest() { alert('Hi Welcome to www.ThaiCreate.Com'); } </script> <asp:Label id="lblText" runat="server" text="Click Here"></asp:Label><br /> <asp:Hyperlink id="hplText" runat="server" text="Click Here"></asp:Hyperlink><br /><br /> <asp:Button id="btnSubmit" runat="server" text="Click Here"></asp:Button><br /> </form> </body> </html>
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class Attribute : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //*** Label ***' { this.lblText.Attributes.Add("OnClick", "alert('Sawatdee');"); this.lblText.Style.Add("cursor", "hand"); } //*** Hyperlink ***' { this.hplText.NavigateUrl = "#"; this.hplText.Attributes.Add("OnClick", "fncTest();"); } //*** Button ***' { this.btnSubmit.Attributes.Add("Onclick", "return confirm('Do you want to...?');"); this.btnSubmit.Style.Add("cursor", "hand"); } } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท