单击后面代码中的链接按钮后如何打开新选项卡 [英] how to open a new tab after clicking a link button from code behind

查看:63
本文介绍了单击后面代码中的链接按钮后如何打开新选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我使用下面的代码打开新标签



Actually i am using below code to open new tab

OnClientClick="var originalTarget = document.forms[0].target; document.forms[0].target = '_blank'; setTimeout(function () { document.forms[0].target = originalTarget; }, 3000);"





以上代码在点击链接按钮时正在使用该链接按钮我正在重定向到一个文件,如pdf,xml



这里我的问题是,如果文件在那里意味着它只是正确打开但如果文件不存在意味着它打开我点击的同一页面,所以我希望从后面的代码做



有没有可能做到这样



the above code is using while clicking on the link button in that linkbutton i am redirecting to one file like pdf,xml

here my problem is if the file is there means it is opening correctly only but if the file is not there means it is opening same page from where i am clicking so i desided to do from code behind

is there any possibility to do like that

推荐答案

试试这个

你可以这样做,就像添加属性一样锚在这里我有锚,你可以使用链接按钮

var url =abc.aspx;

anchor.Attributes.Add(target,_ blank) ;

anchor.Attributes.Add(href,+ url +);
try this
you can do this like by adding attribute in anchor here I have anchor that you can use link button
var url = "abc.aspx";
anchor.Attributes.Add("target", "_blank");
anchor.Attributes.Add("href", "" + url + "");


点击此处 [ ^ ]



如何编写代码以在asp.net中打开新标签,c# [ ^ ]

如果这对您有所帮助,请点击这里。

请如果没有在评论中回复您的查询。

谢谢

:)
Check here[^]
and also
How to code to open new tab in asp.net,c#[^]
Please check here if this helps you.
Please if not post back your queries in comments.
Thanks
:)


这篇关于单击后面代码中的链接按钮后如何打开新选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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