ASP.NET(vb.net) & Attribute.Add() - Attribute.Add() : Learn and example how to use Asp.net and Attribute.Add()
ShotDev Focus:
- ASP.NET(vb.net) & Attribute.Add()
Example
Attribute.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Attribute.aspx.vb" Inherits="Attribute" %> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form id="form1" runat="server"> <script language="JavaScript"> function fncTest() { alert('Hi Welcome to www.ShotDev.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>
Attribute.aspx.vb
Public Class Attribute Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load '*** Label ***' With Me.lblText .Attributes.Add("OnClick", "alert('Sawatdee');") .Style.Add("cursor", "hand") End With '*** Hyperlink ***' With Me.hplText .NavigateUrl = "#" .Attributes.Add("OnClick", "fncTest();") End With '*** Button ***' With Me.btnSubmit .Attributes.Add("Onclick", "return confirm('Do you want to...?');") .Style.Add("cursor", "hand") End With End Sub End Class
Screenshot
3trackless…
…