开发者

asp.net drop down list viewstate issue after client side Ajax update

In my aspx page I have drop down list that initialy in page load event loads up with list of values which is shown to client(drop down list "A") and in client side, depending on client selecion of another drop down list(drop down list "B") I have written a javascript to update drop down list "A" with corresponding values with Ajax behav开发者_开发百科iour(without full page postback).

But when we post page to the server, in server side page load event shows initialy sent list of values for drop down list "A" but not the values that were loaded by Ajax calls due to ViewState not being updated correctly due to Ajax call. I could fix this easily with update panel but it increased Ajax request size to 44KB which is much higher than what currently is for hand made Ajax script I have written( 0.5KB) Is there special way of fixing this rather than using update panel?


You could write small js to store dropdown selected value in hidden field. And use generic HTML control to decrease viewstate size.

$("select#a").change(function(){
 $("input[type='hidden']").val($(this).children(":selected").val()); 
});

 <select id="a" runat...><option ...></select>
 <asp:HiddenField ... />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜