Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 27, 2012 02:56 AM by Frank Jiang - MSFT
Member
42 Points
26 Posts
Feb 25, 2012 04:48 AM|LINK
Hi,
Not done hyperlinks before.
Have page that is populated from a database.
Have a field that I want as a hyperlink.
The page shows a hyperlink and if I click the field it opens another
window showing exactly the same. That is not the destination url.
In the script section I do not know if there should be something in
the window.open(""). Seems that there should be. But what.
Many thanks any assistance.
Relevent code:-
<script type="text/javascript"> function openWindow() { window.open(""); } </script> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="#" onclick="openWindow();"></asp:HyperLink> ============================ if (!Page.IsPostBack) { String ArtistID = Request.QueryString["ArtistID"]; if (ArtistID == "") { Response.Write("Invalid Artist ID"); return; } sqlcmd = new SqlCommand("select tblArtists.ArtistID, tblArtists.ArtistName, tblArtists.Origin, tblArtists.Genre,
tblArtists.WebAddress, tblAlbums.AlbumName, tblYearReleased.YearReleased from tblAlbums INNER JOIN tblArtists
ON tblAlbums.ArtistID = tblArtists.ArtistID INNER JOIN tblYearReleased ON tblAlbums.YearReleasedID = tblYearReleased.YearReleasedID
where tblArtists.ArtistID='" + ArtistID + "' order by tblYearReleased.YearReleased", sqlcon);
sqlcon.Open(); da = new SqlDataAdapter(sqlcmd); dt.Clear(); da.Fill(dt); if (dt.Rows.Count > 0) { TextBox1.Text = ArtistID; TextBox2.Text = dt.Rows[0][1].ToString(); TextBox3.Text = dt.Rows[0][2].ToString(); TextBox4.Text = dt.Rows[0][3].ToString(); TextBox5.Text = dt.Rows[0][4].ToString(); HyperLink1.Text = dt.Rows[0][4].ToString();
All-Star
95275 Points
14072 Posts
Feb 25, 2012 04:57 AM|LINK
opening a page in a new window depends on browser settings, if you configured your browser to open all new windows in new tabs, then what ever you do it really doesnt matter, all window.open() will open in new tabs..
Thanks,
Feb 25, 2012 05:04 AM|LINK
My main problem is that the new page is not showing the url address of the hyperlink.
Feb 25, 2012 05:09 AM|LINK
simple window.open() never works, you got to specify some parameters...
http://msdn.microsoft.com/en-us/library/ms536651(v=vs.85).aspx
Feb 25, 2012 05:29 AM|LINK
I have put _blank as Target in the asp:hyperlink section and left the
rest unchanged. "The sURL is loaded into a new, unnamed window. msdn site says "
All I get now is an blank window. NOT that of the site name.
16006 Points
1728 Posts
Microsoft
Feb 27, 2012 02:56 AM|LINK
Please see examples:
http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
24Kev
Member
42 Points
26 Posts
Hyperlink Only Opens Same Page In New Tab
Feb 25, 2012 04:48 AM|LINK
Hi,
Not done hyperlinks before.
Have page that is populated from a database.
Have a field that I want as a hyperlink.
The page shows a hyperlink and if I click the field it opens another
window showing exactly the same. That is not the destination url.
In the script section I do not know if there should be something in
the window.open(""). Seems that there should be. But what.
Many thanks any assistance.
Relevent code:-
<script type="text/javascript"> function openWindow() { window.open(""); } </script> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="#" onclick="openWindow();"></asp:HyperLink> ============================ if (!Page.IsPostBack) { String ArtistID = Request.QueryString["ArtistID"]; if (ArtistID == "") { Response.Write("Invalid Artist ID"); return; } sqlcmd = new SqlCommand("select tblArtists.ArtistID, tblArtists.ArtistName, tblArtists.Origin, tblArtists.Genre,sqlcon.Open(); da = new SqlDataAdapter(sqlcmd); dt.Clear(); da.Fill(dt); if (dt.Rows.Count > 0) { TextBox1.Text = ArtistID; TextBox2.Text = dt.Rows[0][1].ToString(); TextBox3.Text = dt.Rows[0][2].ToString(); TextBox4.Text = dt.Rows[0][3].ToString(); TextBox5.Text = dt.Rows[0][4].ToString(); HyperLink1.Text = dt.Rows[0][4].ToString();ramiramilu
All-Star
95275 Points
14072 Posts
Re: Hyperlink Only Opens Same Page In New Tab
Feb 25, 2012 04:57 AM|LINK
opening a page in a new window depends on browser settings, if you configured your browser to open all new windows in new tabs, then what ever you do it really doesnt matter, all window.open() will open in new tabs..
Thanks,
JumpStart
24Kev
Member
42 Points
26 Posts
Re: Hyperlink Only Opens Same Page In New Tab
Feb 25, 2012 05:04 AM|LINK
Hi,
My main problem is that the new page is not showing the url address of the hyperlink.
ramiramilu
All-Star
95275 Points
14072 Posts
Re: Hyperlink Only Opens Same Page In New Tab
Feb 25, 2012 05:09 AM|LINK
simple window.open() never works, you got to specify some parameters...
http://msdn.microsoft.com/en-us/library/ms536651(v=vs.85).aspx
Thanks,
JumpStart
24Kev
Member
42 Points
26 Posts
Re: Hyperlink Only Opens Same Page In New Tab
Feb 25, 2012 05:29 AM|LINK
Hi,
I have put _blank as Target in the asp:hyperlink section and left the
rest unchanged. "The sURL is loaded into a new, unnamed window. msdn site says "
All I get now is an blank window. NOT that of the site name.
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: Hyperlink Only Opens Same Page In New Tab
Feb 27, 2012 02:56 AM|LINK
Please see examples:
http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
Feedback to us
Develop and promote your apps in Windows Store