Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to close a page launched from gridview hyperlink

Status
Not open for further replies.

furtivevole

Technical User
Jun 21, 2001
84
0
0
GB
Hi
I have just been asked to take on an existing asp.net project for the first time.
In one case, the results of a search are displayed through a gridview, with one of the columns being defined as a hyperlinkfield. This launches a separate page (currently, target="_blank"). The user would like a close button or similar on the new page, which would be easy enough with a jscript pop-up, but I'm told that gridview cannot support jscript and it would have to be done with C# code. So far I've not been able to google any examples. Can anyone give any insight on this please?
 
but I'm told that gridview cannot support jscript and it would have to be done with C# code.
This person does not understand what they are saying.
1. gridview is just a control to render an html table. it's completely customizable.
2. c# (or vb) is no use. that is server code, what you require is client code (js).

what you require is strictly html, no asp.net required. (you could use an asp:button or asp:Hyperlink, but you don't need too.) just add a button/link (which ever they prefer) and add javascript to close the window.
Code:
<input type=button value="close" onclick=javascript:window.Close();" />
//or
<a href="void();" onclick=javascript:window.Close();">close</a>
there are plenty of examples on line about using html/javascript to close browser windows.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
JMackley, you were right. For reference, this is what I put in the master page:

Code:
<script type="text/javascript">
   function closeme(){
        window.opener = null;
        window.close();
   }
</script>

Within various form pages, a linkbutton included the following property:

Code:
OnClientClick="closeme();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top