In Asp.net datalist, hyperlink transmits parameters and opens a new page.

Source: Internet
Author: User

I recently made a little thing and found that hyperlink Transmission Parameters in datalist are not easy to do. I have found many forums,ArticleI finally found the implementation method and posted it to everyone for sharing!

The Writing Method in the source code of the ASPX page is as follows:

<Asp: hyperlink id = "hyperlink1" runat = "server" width = "177px" navigateurl = '<% # "togoal. aspx? Id = "+ databinder. eval (container. dataitem, "ID") %> '> <% # databinder. eval (container. dataitem, "text") %> </ASP: hyperlink> </TD>

After this, I felt a little unsatisfied, because I want to open a new page, instead of redirecting from the original page.
Response. Write ("<script language = JavaScript> window. Open ('new. aspx '); </SCRIPT> ")
It is considered that the pop-up window is blocked by the browser, so you have to try other methods. Later I found that I could write it below.
<Asp: hyperlink id = "hyperlink1" runat = "server" width = "177px"> <a href = "http://www.sina.com" target = "_ blank"> <% # databinder. eval (container. dataitem, "text") %> </a> </ASP: hyperlink> </TD>

If your link address is obtained from the database, write it as follows:
<Asp: hyperlink id = "hyperlink1" runat = "server" width = "177px"> <a href = '<% # "http: //" + databinder. eval (container. dataitem, "url") %> 'target = "_ blank"> <% # databinder. eval (container. dataitem, "url") %> </a> </ASP: hyperlink> </TD>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.