在每个回发页面上打开一个新选项卡 [英] on every postback page opens in a new tab

查看:62
本文介绍了在每个回发页面上打开一个新选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,



我的页面中有一个奇怪的问题。我有一个名为Print的按钮。我希望报告应该出现在新标签中,所以我在按钮的onClientClick上写了一些javascript。哪个效果很好,没有任何问题。



但是当用户再次回到原始页面时,问题就开始了,现在我在这里有几个导致回发的控件。比如说它是一个下拉列表。因此,每当用户更改下拉项时,它会导致回发,这很好,但每次在每次回发时都会打开一个新选项卡。



希望我有问题...



任何帮助??



这是一个代码:



HI all,

I have a weird problem in my page. I have a button called Print. I wanted report should come in a new tab, so i wrote some javascript on button's onClientClick. Which works great with no problem at all.

But problem starts now when user comes back on original page again, now here i have several controls which cause postback. Say for example its a dropdownlist. so whenever user changes dropdown item it causes postback which is fine but everytime it opens a new tab on every postback.

hope I am clear in question...

Any help??

Here is a code:

<asp:button ID="btnPrint" runat="server" Text = "Print" OnClick="btnPrint_Click" onClientClick="aspnetForm.target='_blank'" />

推荐答案





在页面加载事件检查 IsPostBack 并根据它加载你的设置。
Hi,

On page load event check IsPostBack and load you settings according to that.


我只是清除onLoad上的目标



i just clear the target on onLoad like this

opener.document.getElementById('aspnetForm').target = '';





和这很有效....: - )



and this works great....:-)


首先感谢Hiren,我和li有同样的问题ke你但是使用你的解决方案我把它整理出来



in aspx;

in body section

写下来以下

first of all thanks Hiren, i had a same problem as like you but using your solution i sort it out

in aspx;
inside body section
write the following
<body onload="fixform()"> 





然后写一个javascript



then write a javascript

<script type="text/javascript">
    function fixform() 
    {
        document.getElementById("Form1").target = '';       
    }



记住你已经设置了target ='_ blank'onClientClick

for viz。:


remember you have set target ='_blank' onClientClick
for viz.:

<asp:button id="btnPrint" runat="server" text="Print" onclick="btnPrint_Click" onclientclick="Form1.target='_blank'" xmlns:asp="#unknown" />


这篇关于在每个回发页面上打开一个新选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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