简体   繁体   中英

unable to get the value of button inside update panel

Team,

When I click on the first add template button then the download value disappear. 在此处输入图片说明 .

在此处输入图片说明

window.onload = function() {
    ddnameChange();
};
function ddnameChange() {
    var e = document.getElementById("<%=ddltemplate.ClientID %>");
    var ddnamevalue = e.options[e.selectedIndex].value;    
    if(ddnamevalue==2)
    {       
        <%=btndownload.ClientID %>.value="Download RBH Template";

    }
    else if(ddnamevalue==3)
    {
        <%=btndownload.ClientID %>.value="Download VISTA Template";
    }
    else
    {
        <%=btndownload.ClientID %>.value="Download OD Template";  
    }
}

I am not able to get the second button value when i click on edit as well as all template button.I know it should be something reason like update panel that why the function is not calling I don't know how to solve it.

You have to add this in the method that handles the Async PostBack.

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ddnameChange", "ddnameChange();", true);

When the Async PostBack occurs, everyting inside the UpdatePanel is rebuild and anything that has been altered by jQuery will be lost.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM