문제

I have a single drop down in a jQuery Modal popup . When a row in a repeater is selected I show the modal and use jQuery to set the appropriate item in the drop down. When the item in the dropDown changes I do a postback and save the new values.

My problem is that sometimes the SelectedIndexChanged event for the DropDown does not fire. This happens if my jQuery changes the value and the users changes it back to the default. The server does not know there was a change.

Suppose I have these color values in the drop down: Text - Value

Unknown - 0 Red - 1 Blue - 2

The dropdown defaults to a value of 0 – an unknown color. The users pick a repeater row that has a Red color and jQuery sets the dropDown to a value of 1 (for red). The user changes the selection to Unknown – a value of zero.

The postback occurs, but the SelectedIndexChanged event does not fire. The reason is that the serverSide thinks the value did not change - the original value was 0 and the new value is 0. It does not know that jQuery changed it to 1.

Does anyone know a good workaround for this? I hate to do a postback when the modal is shown just to sync the server side.

도움이 되었습니까?

해결책

Have a hidden input in your form, set its value to something using javascript when appropriate and check it on the server side during postback.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top