Consider the scenario where:
- an ASP.NET webform page has a DropDownList and a ListView.
- this DropDownList must set a cookie value on its
OnSelectedIndexChangedevent. - 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.
1) For getting value of DropDownList:
2) Loading ListView:
a. For this I will suggest consulting Dave’s postings at his site Encosia.
b. Rick Strahl also has great post on is blog regarding using jQuery ajax
c. Muhammad Mosa has post describing Master-Detail scenario with ajax