简体   繁体   中英

Adding new query parameter to hyperlinks dynamically

I have several hyperlinks in my homepage. I would like to add a query parameter at the end of each hyperlink dynamically.

For example;

<a href="detail.aspx?id=2" target="_blank" >xyz</a>
<a href="detail.aspx?cid=5" target="_blank" >pqr</a>

will be converted to

<a href="detail.aspx?id=2&redirectFrom=hp" target="_blank" >xyz</a>
<a href="detail.aspx?cid=5&redirectFrom=hp" target="_blank" >pqr</a>

a new query parameter " redirectFrom " with value have been added to the converted hyperlinks.

How I can achieve it using ASP.net C#?

Maybe you can use Request.UrlReferrer.AbsolutePath instead of dynamically modifying each Link in your page. Please make sure whether or not UrlReferrer is null or not with every Request.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM