单击后面代码中的链接按钮后如何打开新选项卡
问题描述:
实际上我使用下面的代码打开新标签
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
:)