.NET 取得網頁上html的Attribute
.NET 取得網頁上html的Attribute
先要讓要控制的項目runat="server" 再給他一個id
前端HTML
後端程式碼
HtmlGenericControl MyHtmlControl = (System.Web.UI.HtmlControls. HtmlGenericControl)FindControl("nav03" );
//改變控制項class屬性
MyHtmlControl.Attributes["class"] = "nav03 navFocus03"
//給予控制項一個myAttribute的屬性 並賦予Test的值
MyHtmlControl.Attributes.Add("myAttribute", "Test")