I have a dropdown list whose auto postback is set to true and selectedindexchanged event is used for some logic. But the condition is when other data is changed on the page i need to warn user about the changes by showing a confirmation dialogue. I am using javascript to do this but the problem is post back is not happening even when the function returns true. I have no idea whats wrong. Can some body help regarding this.
function ValidateDataChange() {
var isDataChanged = $('#<%=hdnDataIsChanged.ClientID %>').val();
if (isDataChanged == "True") {
alert(isDataChanged);
return false;
}
return true;
}
<asp:DropDownList ID="ddlHierarchy" runat="server" AppendDataBoundItems="true" AutoPostBack="true"
onchange="return ValidateDataChange();" Enabled="false" OnSelectedIndexChanged="ddlHierarchy_SelectedIndexChanged">
<asp:ListItem Value="" Text="--Select Hierarchy--"></asp:ListItem>
</asp:DropDownList>
<asp:HiddenField ID="hdnDataIsChanged" runat="server" />
protected void ddlHierarchy_SelectedIndexChanged(object sender, EventArgs e)
{
//mycode
}