asp.net用户控件,获得的HtmlAnchor决心HREF ="#" [英] asp.net user control, getting htmlAnchor resolve to href="#"

查看:96
本文介绍了asp.net用户控件,获得的HtmlAnchor决心HREF ="#"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让服务器控件的HtmlAnchor有HREF =#。它使解决#来控制路径。

How do you get a server control HTMLAnchor to have href="#". It keeps resolving the "#" to the control path.

<a href="#" runat="server" />
resolves to: <a href="../ControlPath/#">

我似乎无法获得谷歌搜索给我我想要所以我想我会问这里的结果。

I can't seem to get a google search to give me the results i want so i figured i'd ask here.

编辑:语法

卸下RUNAT服务器不是一个选项。它在后台操纵的,这只是一个简化。

Removing the runat server is not an option. It's manipulated in the backend, this was just a simplification.

推荐答案

我有同样的问题,这里是我怎么能解决这个问题:

I had the same problem, here's how I could resolve it:

原文code

用户控制:

<a id="foo" runat="server">...</a>

背后code:

foo.Attributes.Add("href", "#");

输出:

<a id="..." href="../Shared/Controls/#">...</a>

更新code

用户控制:

<asp:HyperLink id="foo" runat="server">...</asp:HyperLink>

背后code:

foo.Attributes.Add("href", "#");

输出:

<a id="..." href="#">...</a>

这篇关于asp.net用户控件,获得的HtmlAnchor决心HREF =&QUOT;#&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆