你怎么设置锚标记是在code中继器背后内href属性? [英] How do you set href attribute of anchor tag that is within a repeater in code behind?
本文介绍了你怎么设置锚标记是在code中继器背后内href属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通常在会使用下列内容: -
normally on would use the following :-
aspx页面: -
aspx page:-
<a ID="a1" href="javascript:void(0);">Link1 </a>
背后code: -
code behind:-
a1.HRef="www.mySite.com/mypage.aspx";
您是如何的情况下,设置此href属性锚标记是一个中继器内?
how do u set this HRef attribute in case the anchor tag is within a repeater ?
推荐答案
例如,在的ItemDataBound
事件:
protected void rptData_ItemDataBound(object source, RepeaterCommandEventArgs e)
{
HtmlAnchor a1 = (HtmlAnchor)e.Item.FindControl("a1");
a1.HRef = "www.mySite.com/mypage.aspx";
}
另外,不要忘了把 =服务器
在锚
<a ID="a1" runat="server" href="javascript:void(0);">Link1 </a>
这篇关于你怎么设置锚标记是在code中继器背后内href属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文