问题描述:

I have a page that has a linkbutton that opens a report. On this linkbutton if have OnClientClick="aspnetForm.target ='_blank';" so the report opens in a new window/tab. This works as expected. I also have a regular button.

If the linkbutton is clicked first the second button also opens a new window when clicked. How do I stop this from happening?

I don't really know how to phrase the question properly so feel free to edit the question.

网友答案:

Your code for clientClick on LinkButton modifies the whole form target. You can probably just add

OnClientClick="aspnetForm.target ='_self';"

to the second (regular) button. This will again reassign form target - this time to 'self'.

网友答案:

The issue is you're reassigning the value of aspnetForm.target when you click the first button. Instead of this approach, why not use window.open instead?

OnClientClick="void(window.open('http://www.google.com')); return false;"
网友答案:

can you please try to render an HTML anchor(instead of asp:linkbutton) with href set to appropriate url and set the target attribute to _blank

<a href="urlOfThePage" target="_blank" >Click me</a>
相关阅读:
Top