I have javascript writing a cookie just after the HEAD tag. I can retrieve the cookie with vb.net on the postpack of the page, but not on the Page Load event of that initial rendering. Is there a way I can write the cookie if js and access the value in .net in that same initial rendering?
I think I need a trigger event fired after page load (or a delay?). I have also tried writing the value to a text field and reading it from there, but the value is not there yet when the code checks, but it is there when the page is finally loaded, so it's pretty clear I'm asking too early in the cycle.
IMPORTANT. This value is used to load custom images on the screen, so it needs to be as early as possible.
Here is what I am doing. I need some guidance in the best way to incorporate ajax to accomplish it.
I have developed a responsive site that works well with any device, including mobile-- but I want to deliver smaller images to speed up the loading for slow/smaller screens. Thus far:
1) I clock the download of a small (20k) image to get a rough estimate of client's connection.
2) Using jquery, I also get the screen width.
3) I then categorize the enviorment as width+speed (i.e. smallslow, smallfast, bigslow, bigfast)
4) I store this single variable in a cookie which is available on all subsequent page calls.
5) Image tags are loaded initially without a specified src in the aspx file.
In .net code on subsequent pages, I can retrieve the cookie and set images src using this variable in a select case.
THE PROBLEM:
The very first time a client request a page from the site, this cookie is not available to the .net Page Load event. I need to pass it back to the aspx page while the page is loading that first time.
I have not been able to find an example of how to do this with ajax. Is there a way to do this?