使用带有查询字符串变量的链接打开新选项卡?
首先,我对网络开发完全陌生,所以如果这个问题过于简单,我提前道歉(尽管我在发布之前确实做了先决条件谷歌搜索)。
我遇到的问题是我想通过页面上的链接按钮或链接打开一个新选项卡。我需要将页面中的查询字符串变量附加到引用的末尾,因为它将参数传递给报表。
我已成功传递参数并使用以下代码在同一选项卡中打开报告:
protected void lbSummary_OnClick(object sender, CommandEventArgs e)
{
Response.Redirect("http://myreportserverURL&rs:Command=Render&Year="+YearID);
}
并且我已成功在新选项卡中打开报告,而无需使用以下代码传递参数:
<a href="http://myreportserverURL" target="_blank" class="menu">Report Name</a>
我更愿意同时执行这两个操作。一个重要的注意事项是,我不需要打开一个新窗口,而不是一个新选项卡。我确实知道这在某种程度上取决于浏览器的使用,但对于这个项目,我可以假设用户将使用 IE8。
这可能吗?任何建议将不胜感激。
First of all, I am entirely new to web development, so I apologize in advance if this question is overly simple (although I did do the prerequisite googling before I posted).
The problem I am having is that I would like to open a new tab via a link button or link on my page. I need to append a query string variable from the page onto the end of the reference, because it is passing a parameter to a report.
I've successfully passed the parameter and opened the report in the same tab using this code:
protected void lbSummary_OnClick(object sender, CommandEventArgs e)
{
Response.Redirect("http://myreportserverURL&rs:Command=Render&Year="+YearID);
}
And I've successfully opened the report in a new tab without passing the parameter with this code:
<a href="http://myreportserverURL" target="_blank" class="menu">Report Name</a>
I would prefer to do both. One important note is that opening a new window, instead of a new tab, is not what I need. I do understand that this is somewhat dependant on browser use, but for this project I can assume that users will be on IE8.
Is this possible? Any suggestions would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 asp.net 超链接控件,您可以在代码隐藏中将其 NavigateUrl 设置为您想要的任何链接,包括您的查询字符串。
您可以根据需要设置其目标属性。
You can use asp.net HyperLink control where you can set it's NavigateUrl in code-behind to whatever link you want including your querystring in there.
You can set it's Target Property as per you need.
设置 target="_tab" 这将在新选项卡中打开链接
Set target="_tab" this will open link in new tab