Click here to Skip to main content
15,900,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I need to add the query of the current page to the NavigateURL( which is used in one of the control in the same page). I have to do it on the front end(i.e).aspx page rather than the back end. I have explained a small example of What my requirement is..

Consider I have a Page called "Hello.aspx". This has id="1" as query string

In Hello.aspx
I have a control say HyperLink say helloHyperLink. I have to assign the same query that is in the current page to the NavigateUrl tag eg: NavigateUrl="something("Welcome.aspx")". here the welcome.aspx is called with the same parameters that the Hello.aspx have.
Posted
Comments
leonidasvijay 16-Sep-13 5:52am    
do you want to send a value from the hello page to welcome page?

We can use Javascript for that

Hyperlink to call the javascript can be given as below

<asp:HyperLink ID="hyperLnk" runat="server" Text="click here" NavigateUrl="javascript:openWinNavigateUrl()"></asp:HyperLink>


and the Javascript can be given as

C#
function openWinNavigateUrl() {
            // getting the query string
            var query = document.location.href;

           // Getting the index of required parameter. here I use parameter "id"
            var n = query.indexOf("id");

            //removing the parameter name
            var queryString = query.substring(n + 3, query.length);

            //here I use the querystring to open the new Window
             window.open("Window.aspx?id=" + queryString);
        }
 
Share this answer
 
v2
Have a look at ASP.NETs Request object:

i.e.:
HTML
NavigateUrl='<%=Request.RawUrl%>'


... or to navigate to another page passing the querystring parameters
HTML
NavigateUrl='<%=string.concat("Welcome.aspx?", Request.QueryString)%>'


Hope this helps.
 
Share this answer
 
v2
Comments
Prasaad SJ 17-Sep-13 0:56am    
hi.
The solution is not working. It is forming the URL as below

"http://localhost:63994/%3C%=string.concat(%22Window.aspx?%22,Request.QueryString)%20%%3E"
hypermellow 17-Sep-13 4:00am    
eh, no ... the solution does NOT produce the URL: "http://localhost:63994/%3C%=string.concat(%22Window.aspx?%22,Request.QueryString)%20%%3E"

The script between Embedded Code Block (i.e. - the contents of <% %>) will run, rather than append the text to the NavigateUrl property.

If you don't know how script blocks work, have a read about them here: http://msdn.microsoft.com/en-us/library/ms178135%28v=vs.100%29.ASPX

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900