codebehind中如何设置转发器内锚标签的href属性?通常会使用以下内容:-aspx页面:-Link1代码隐藏:-a1.HRef="www.mySite.com/mypage.aspx";如果锚标记位于转发器内,如何设置此HRef属性?例如,在ItemDatabound事件中:a1.HRef="www.mySite.com/mypage.aspx";此外,不要忘记将runat="server"Link1放在该锚点上。您可以在ItemDatabound事件中执行此操作。查看:http://www.codeguru.com/csharp/.net/net_asp/tutorials/article.php/c12065首先你需要通过输入runat="Server"Link1protectedvoidrptOuter_ItemDataBound(objectsender,RepeaterItemEventArgse){if((e.Item.ItemType==ListItemType.Item)||(e.Item.ItemType==ListItemType.AlternatingItem)){//在这里找到你的锚点}}在事件ItemDatabound中执行此操作:以上就是C#学习教程:如何在代码后面的转发器中设置锚标签的href属性?如果分享的内容对你有用,需要了解更多C#学习教程,希望你多多关注——((HtmlAnchor)e.Item.FindControl("a1")).HRef="www.mySite.com/我的页面.aspx";本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
