|
| |
|
|
lovduv
Posts: 152 Joined: 8/30/2005 Status: offline
|
***solved*** asp variable+Javascript url - 2/12/2007 16:47:22
This a carry over from a post I made in ASP and Database, but I thought it may be better suited for this forum: Ok so I have a DetailsView control running on a page...works fine I have a javascript powered by another site on the same page....works fine In the javascript there is a link which passes a variable to the other site i.e <script type="text/javascript" src="http://www.somesite.com/cool.asp?nick=nick name"></script> That link displays the "nickname" info from the other site in the script on my page In my Database I have records of these nick names and show a specific "nick name" and that nick name's info from my DB in the DetailsView control on my page. Under that I display the javascript for the other site. I want to update the java script url above with the nick name from my page. The field name in my Database for nick names is "Nname". How would I pass the value for "Nname" into the url in red above? So it would then be <script type="text/javascript" src="www.somesite.com/cool.asp?nick="Nname Value" "></script> I tried this, but it didn't work. <script type="text/javascript" src="www.somesite.com/cool.asp?nick=<%QueryStringField="Nname"%>"></script> I think I might need to declare the variable, but I thought I already did that in my DetailsView?
< Message edited by lovduv -- 2/13/2007 7:28:10 >
|
|
|
|
lovduv
Posts: 152 Joined: 8/30/2005 Status: offline
|
RE: Variable value into a hyperlink??? - 2/12/2007 17:15:36
Just tried declaring it this way still nothing.....any ideas??? <% Dim varNname varNname = Request.QueryString("Nname") %> <script type="text/javascript" src="www.somesite.com/cool.asp?nick=<%QueryString="varNname"%>"></script>
|
|
|
|
blockhead
Posts: 50 Joined: 6/22/2004 Status: offline
|
RE: Variable value into a hyperlink??? - 2/12/2007 20:57:35
How about: <% Dim varNname varNname = Request.QueryString("Nname") %> <script type="text/javascript" src="www.somesite.com/cool.asp?nick=<%=varNname%>"></script>
|
|
|
|
lovduv
Posts: 152 Joined: 8/30/2005 Status: offline
|
RE: Variable value into a hyperlink??? - 2/12/2007 21:57:31
Just in case it helps this is the whole page...... <body> <form id="form1" runat="server"> <asp:DetailsView runat="server" Width="273px" Height="50px" id="DetailsView1" AutoGenerateRows="False" DataSourceID="nicklisting"> <Fields> <asp:boundfield DataField="Nname" SortExpression="Nname" HeaderText="Nick Name: "> <ItemStyle ForeColor="Red" /> <HeaderStyle BackColor="YellowGreen" Font-Names="Verdana" Font-Bold="True" /> </asp:boundfield> </Fields> </asp:DetailsView> <asp:AccessDataSource runat="server" ID="Nicklisting" DataFile="nicks.mdb" SelectCommand="SELECT DISTINCT [Nname] FROM [Results] WHERE ([Nname] = ?) ORDER BY [Nname]"> <SelectParameters> <asp:querystringparameter Type="String" Name="Nname" QueryStringField="Nname" /> </SelectParameters> </asp:AccessDataSource> </form> <br/> <div> <script type="text/javascript"> nick_width = '350px'; nick_border_color = '#000'; nick_header_background = '#eee'; nick_header_color = '#000'; nick_header_size = '14px'; nick_image_show = 'yes'; nick_image_align = 'left'; nick_body_color = '#000'; nick_body_size = '12px'; nick_new_window = 'yes'; varNname= Request.QueryStringField("Nname") </script> <script type="text/javascript" src="http://www.somesite.com/cool.asp?nick=<%=("varNname")%>"></script> </div> </body>
|
|
|
|
lovduv
Posts: 152 Joined: 8/30/2005 Status: offline
|
ANSWER - 2/13/2007 7:27:23
Ok I was able to do this finally...hope it helps someone! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ Page Language="C#" %> //Had to add this here// <script runat="server"> protected void Page_Load(object sender, EventArgs e) { Page.DataBind(); } </script> // end page load// <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Nick Listing</title> </head> <body> <form id="form1" runat="server"> <asp:DetailsView runat="server" Width="273px" Height="50px" id="DetailsView1" AutoGenerateRows="False" DataSourceID="nicklisting"> <Fields> <asp:boundfield DataField="Nname" SortExpression="Nname" HeaderText="Nick Name: "> <ItemStyle ForeColor="Red" /> <HeaderStyle BackColor="YellowGreen" Font-Names="Verdana" Font-Bold="True" /> </asp:boundfield> </Fields> </asp:DetailsView> <asp:AccessDataSource runat="server" ID="Nicklisting" DataFile="nicks.mdb" SelectCommand="SELECT DISTINCT [Nname] FROM [Results] WHERE ([Nname] = ?) ORDER BY [Nname]"> <SelectParameters> <asp:querystringparameter Type="String" Name="Nname" QueryStringField="Nname" /> </SelectParameters> </asp:AccessDataSource> </form> <br/> <div> <script type="text/javascript"> nick_width = '350px'; nick_border_color = '#000'; nick_header_background = '#eee'; nick_header_color = '#000'; nick_header_size = '14px'; nick_image_show = 'yes'; nick_image_align = 'left'; nick_body_color = '#000'; nick_body_size = '12px'; nick_new_window = 'yes'; varNname= Request.QueryStringField("Nname") </script> //And Change this// <script type="text/javascript" src='<%# "http://www.somesite.com/cool.asp?nick=" + Request.QueryString["Nname"] %>'></script> </div> </body> </html>
|
|
|
|
mar0364
Posts: 3221 Joined: 4/5/2002 From: Florida, US Status: offline
|
RE: ANSWER - 2/15/2007 10:28:50
Thanks for marking it solved and sharing your solution. Thats how we all learn. Rich
_____________________________
Easy Web “Stay committed to your decisions, but stay flexible in your approach.”
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|