开发者

ASP.net c# make hyperlink point to page anchor

// Post quote
GDQ.CssClass = "s comment-quote";
GDQ.ToolTip = "Quote this post";
GDQ.NavigateUrl = "#Post";

And on my page I have:

<a name="Post"></a>

However, this url points to:

http://127.0.0.1/Site/Controls/#Post

Which is the path that the user control is in, I need it to jump to the #Post on whatever page the control exists on.

I can do:

GDQ.NavigateUrl = Page.Request.Url +  "#Post";

But the URL开发者_运维问答 I am on is rewritten, which points it to the actual filename which sends a new request. I just want it to jump on the current page.


This looks like it fixes it: Using HtmlAnchor or ASP.NET HyperLink for anchor tag that navigates in-page named anchor

So, in your case:

GDQ.Attributes["href"] = "#Post";


First the anchor has no name attribute, I think you wanted to write href instead of name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜