获取超链接的NavigateUrl属性为刚刚"#myhashtag" [英] Get HyperLink's NavigateURL property as just "#myhashtag"

查看:265
本文介绍了获取超链接的NavigateUrl属性为刚刚"#myhashtag"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在它的超链接控件的用户控件。该应用程序的数据库驱动(这是kentico)。

I have a user control with a hyperlink control within it. The application is database driven (it's kentico).

我需要设置来设置超链接的NavigateUrl属性为#部分-1。当我这样做,asp.net是转换用户/ MyFolder中/用户控件/#部分-1。这不是甚至是在浏览器的URL,并打破一些现有的JavaScript code我的工作。

I need set to set the hyperlink's navigateurl property to #section-1. When I do so, asp.net is converting the user to /myfolder/usercontrols/#section-1. That's not even the URL that was in the browser, and breaks some existing javascript code I'm working with.

怎样才能轻松搞定超链接的NavigateUrl属性来呈现一个干净的#部分-1?

How can I easily get the hyperlink's navigateurl property to render as a clean "#section-1"?

是的,我需要一个服务器端控制。

Yes, I need a server side control.

如果我手动建立完整的请求的URL,甚至与〜/ ...,asp.net使得它作为一个服务器相对URL ,当时我只想要一个干净的HREF =#部分-1。

If I build the full request URL manually, even with "~/...", asp.net renders it as a server relative URL, when I just want a clean href="#section-1".

推荐答案

你试过:

HyperLink1.Attributes.Add("href","#section-1")

HyperLink1.Attributes("href") = "#section-1" 'overwrite any existing href

这篇关于获取超链接的NavigateUrl属性为刚刚"#myhashtag"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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