我在 li.Attributes.Add("class", "current") 上收到空异常错误
母版页:
<ul>
<li id="li01"><a href="page1.aspx" title="Page 1">Page 1</a</li>
<li id="li02"><a href="page2.aspx" title="Page 2">Page 2</a></li>
<ul>
后面的页面代码:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim li As System.Web.UI.HtmlControls.HtmlGenericControl = DirectCast(Me.Page.Master.FindControl("li02"), System.Web.UI.HtmlControls.HtmlGenericControl)
li.Attributes.Add("class", "current")
End Sub
谢谢。