I have a DropDownList which has two options yes and no. I am using onchange event right now but it does not get fired the first time page is loaded with value yes in the dropdownlist.(since values has not been changed yet.) I want to set the visibility of controls depending on the current value of the dropdownlist.
ASPX
<asp:DropDownList ID="ddlAriba" onchange="ddlAribaChange(this);" runat="server"              ClientIDMode="Static" CssClass="FormText" AutoPostBack="True">
    <asp:ListItem Value="Y" Selected='True'>Yes</asp:ListItem>
    <asp:ListItem Value="N">No</asp:ListItem>
</asp:DropDownList>
JAVACRIPT
function ddlAribaChange(ddl) {
    var txtAribaDocumentNumber = document.getElementById("txtAribaDocumentNumber");
    var ddlAribaReason = document.getElementById("ddlAribaReason");
    //alert(ddl.options[ddl.selectedIndex].text);
    if (ddl.options[ddl.selectedIndex].text == 'Yes') {
        txtAribaDocumentNumber.style.display = 'inherit';
        ddlAribaReason.style.display = 'none';
    } else {
        txtAribaDocumentNumber.style.display = 'none';
        ddlAribaReason.style.display = 'inherit';
    }
}
 
     
     
     
    