It is running your code twice on clicking Ok, because you have explicitly mentioned Form1.submit() in your code of adding the attribute. Also, it returns true, which again calls the server SelectedIndexChanged event. On Cancel, it cancels your last event, means it cancels the drop down list selection so it displays the last selected value, not the current value. For first problem, i.e. on clicking of Ok, write the code as follow:
cbDayType.Attributes.Add("onchange", "if (confirm('Do Are you sure you want to update Date?')) return true; else return false;")
|