当我点击锚标记时,页面获得回发并且什么都不做
代码如下所示,
System.Web.UI.HtmlControls.HtmlAnchor anchor1 = new System.Web.UI.HtmlControls.HtmlAnchor();
anchor1.InnerText = "Edit";
anchor1.Attributes.Add("runat", "server");
anchor1.Attributes.Add("onServerClick", "anchor1_Click");
anchor1.Style.Add("color", "blue");
anchor1.Style.Add("float", "right");
protected void anchor1_Click(object sender, EventArgs e) {
ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('Enter Value For Drop Down Name');", true);
}
答案 0 :(得分:1)
请试试这个
anchor1.ServerClick += new EventHandler(anchor1_Click);
答案 1 :(得分:0)
尝试这样的尝试,
protected void Page_Load(object sender, EventArgs e)
{
System.Web.UI.HtmlControls.HtmlAnchor anchor1 = new System.Web.UI.HtmlControls.HtmlAnchor();
anchor1.InnerText = "Edit";
anchor1.Attributes.Add("runat", "server");
anchor1.Style.Add("color", "blue");
anchor1.Style.Add("float", "right");
anchor1.ServerClick += new EventHandler(anchor1_Click);
}
protected void anchor1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('Enter Value For Drop Down Name');", true);
}