Maybe it's just a big fuss. Now I found that the target attribute of hyperlink can be used like this.
Let's take a look at asp.net's ASP. NET Articles -- Updated Daily! Click the link to open an article in a new window. Do not close the new window. Click the link of another article to find that the new link does not open a new window, instead, load it in the previously opened window, so that we can avoid opening too many new windows.
Curious. I checked the source code, but I checked msdn and found that the target attribute is explained as follows:
Possible Values
STarget |
StringThat specifies or distinct es one of the following values.
Name |
The name of the target window or frame. |
_ Blank |
Load the linked document into a new blank window. This window is not named. |
_ Media |
Load the linked document into the HTML content area of the Media Bar. Available in Internet Explorer 6 or later. |
_ Parent |
Load the linked document into the immediate parent of the document the link is in. |
_ Search |
Load the linked document into the browser search pane. Available in Internet Explorer 5 or later. |
_ Self |
Default. Load the linked document into the window in which the link was clicked (the active window ). |
_ Top |
Load the linked document into the topmost window. |
|
The property is read/write. The property has a default value of _ self.
Let's see why I marked it in red. Hyperlink in asp.net's article list sets this attribute target = "_ new ".
I tried the following code and made the same effect.
AspnetUpload.net
Upload4Asp.net
But it is a little bad. After I open a new page, I return to the home page and click another link. Although the new link has been loaded, it does not automatically get the focus, but stays on the home page. A solution is to add javascript code to the new page:
<Script language = javascript>
Script>
Obtain or set the URL to be linked when you click the HyperLink control.
Namespace: System. Web. UI. WebControls
Assembly: System. Web (in system. web. dll)
Attribute Value
Click the URL to which the HyperLink control is linked. The default value is an empty string ("").
Example
<% @ Page Language = "C #" AutoEventWireup = "True" %>
<Html>
<Head>
</Head>
<Body>
<H3> HyperLink Example
Click on the HyperLink: <br>
<Asp: HyperLink id = "hyperlink1"
ImageUrl = "images/pict.jpg"
NavigateUrl = "http://www.microsoft.com"
Text = "Microsoft Official Site"
Target = "_ new"
Runat = "server"/>
</Body>
</Html>
Version Information
. NET Framework
Supported by the following versions: 2.0, 1.1, and 1.0