LinkButton的href网址 [英] Linkbutton href url
本文介绍了LinkButton的href网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的code动态linkbuttons一个循环,我想设置OnClientClick属性开辟一个新的浏览器窗口中的链接。这听起来很简单,但我有一点麻烦得到它的工作。
I have a loop in my code with dynamic linkbuttons and I want to set the OnClientClick property to open up the link in a new browser window. It sounds simple but I am having a bit of trouble getting it to work.
lbUrl = new LinkButton();
lbUrl.Text = r["Url"].ToString();
// r["Url"] is Datarow
lbUrl.OnClientClick = "location.href=" + r["Url"].ToString();
任何想法?
推荐答案
window.open()
将在新的浏览器标签/窗口中打开链接
window.open()
will open the link in a new browser tab/window
lbUrl.OnClientClick = String.Format("window.open('{0}')", r["Url"]);
确保您的网址是绝对网址
这篇关于LinkButton的href网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文