I have an ASP.NET page that contain a form that search the page.
Is there any solution so that I can have the search text in the URL?
I want to give the posibility to my clients to copy/paste the search results URL.
I have an ASP.NET page that contain a form that search the page.
Is there any solution so that I can have the search text in the URL?
I want to give the posibility to my clients to copy/paste the search results URL.
You can also use jQuery to do the trick, like this:
If you want the ability to copy/paste the URL, you will need to get the search parameters from the form and redirect back to the form with the search parameters on the URL, then read the QueryString values to perform the search.
There might be other better/cleaner/proper ways of doing it, like changing form's action, or changing button's PostBackUrl, but this is what I would do.
.aspx:
.cs:
After more research abut this topic I think that the javascript solution is the best:
You can access the ACTION attribute of the form using JavaScript.
Personally I am not a big fan of JavaScript ... but this does not add an extra request to the server. If you think that this has any drawbacks please let me know.