When you btnSearch click event, you make a full return back to the server. As a result, your ASPX page gets rendered based on how you defined it on the ASPX page above. In this case, div_date , div_status and div_subject displayed with a none display. And your select list will reset for the default item (which will be the first ListItem).
You need to keep track of what is visible and what is selected before the postback, if you want to keep the same behavior (full postback). I have a few thoughts on how to handle this.
You might want to have a hidden input element whose value you set in each if {} expression in your JavaScript .change() handler. If this hidden value is set to runat="server" , you can more easily get its value on the server during your Page_Load , and then set the correct visibility of your div (although those runat="server" should also be runat="server" if you donβt visualize them dynamically.
<input type="hidden" id="hidCriteria" runat="server" />
and your JavaScript will have ...
$("#hidCriteria").val("DATE"); //or "STAT" or "SUBJ" depending on what selected
in each if(sel == 'xxx') section if(sel == 'xxx') to keep track of what is visible.
I think you can also change div_date, div_status and div_subject to asp: Panel, and I think that their state (visible or not) will be stored in viewstate and saved in the postback. I'm not 100% sure, but it might be a simpler test to try it out before hidden input control.
Something else needs to be considered if the btnSearch click btnSearch is to save the user on one page, maybe you can associate the btnSearch click event with a jQuery $.ajax() call to make asynchronous write to the server to do its job and save your user interface without postback. You can do it:
$("#btnSearch").click(function() { $.ajax({ url: 'myService.svc/DoSearch', //url you're posting to, type: 'POST', dataType: 'json', //up to you...could be 'xml', 'text', etc. data: { //your search criteria here }, ... }); });
Sorry if this was a long time. Hope this helps!