Jump to content

Grabbing part of the url


ZeroShade

Recommended Posts

It doesn't work because the client doesn't have access to the server-side Request object. You'll either have to manually parse the string in javascript or wrap that Request.QueryString part in tags to tell the page to run that code at the server. Perhaps something like this:

<script type="text/javascript">		function GoBack()		{			var discussionId = <%=Request.QueryString("DiscussionId")%>;			document.write("Threads.aspx?DiscussionId=" + discussionId);		}</script>

Since it looks like you're using .NET, the better way would probably be to take care of all of that on the server:ASPX:

<asp:HyperLink id="ThreadLink" runat="server" Text="Read the Discussion" />

C# Code-behind:

ThreadLink.NavigateUrl = "Threads.aspx?DiscussionId=" + Request.QueryString["DiscussionId"];

Link to comment
Share on other sites

You can also make most, if not all, of the traditional HTML tags runat server as well:

<a id="ThreadLink" runat="server">Read the Discussion</a>

ThreadLink.Href = "Threads.aspx?DiscussionId=" + Request.QueryString["DiscussionId"];

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...