Consider the scenario where:
- an ASP.NET webform page has a DropDownList and a ListView.
- this DropDownList must set a cookie value on its
OnSelectedIndexChanged
event. - the DropDownList is also set to
AutoPostBack="True"
to force the ListView to reload using the DropDownList's new value. - the page is referencing current JQuery libraries, including the great set of cookie plugins
This code will be used in the assignment of the value of the cookie:
var date = new Date();
date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
$.cookie('cookieName', 'theValue', { path: '/', expires: date });
Question: Can you suggest how to have the DropDownList's value extracted and saved to a cookie using jQuery? Super bonus points for an answer including how to call the post-back method to rebind the ListView! I would definitely love to save a post-back 'flash' for the user.