1

In my page I have an ajax call for search and filtering and all the filter selection I am appending in URL as a # param (as appending in form of query string it will refresh the page).

By my problem is that I am not able to access this (# values) in my code behind (using c#).

I tried to store the # value in hidden field on window.load function of javascript, but I will not get this value in page load method of asp.net.

Can anybody suggest how to access this value on page load?

4
  • You need to provide some more information! May be some javascript and page code + some server code! What do you mean by "# value in hidden field on window.load function of javascript"? Commented Aug 3, 2013 at 16:33
  • In my page there is a Search button which triggers an ajax call, All the input field value as well all the selected filter value are taken an input parameter for ajax call.After the ajax response I am storing all this value on url like this : mysite/PR.aspx#l=20&text=Giyt&pg=20 This # values I need to access in my code behind Commented Aug 3, 2013 at 16:36
  • Did you try $(form).serialize()? jquery Commented Aug 3, 2013 at 16:40
  • I am able to set the values in URL and also I am able to get the value using jquery but I am not able to find any way to access this value in aspx.cs file using c# Commented Aug 3, 2013 at 16:45

1 Answer 1

1

Well, # is not sent to the server (it's not in the request), you can access it through javascript though, something like:

var hash = window.location.hash;
if (hash !== "") {
    hash = hash.substring(1);
    alert(hash);
}

If you have to access it on the server, I'm affraid you have to place a query string:

http://yoururl/?test=123

Then you access with: Request.QueryString["test"] - will get you 123.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks but how to access this value in the code behind file using c#.
I want to find the way to access this value using c#
I tried to set this hash value in hidden field using jQuery, but on Page_Load method I wont be able to get this value.
As this values I am setting during the ajax call and if I set in the form of proper query string then it will reload the page and will kill purpose of using ajax.
@user1803513 I don't see how that's an issue ? Ajax -> send the value to the server -> do stuff there -> get results ? No reload, really.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.