1

Team,

When I click on the first add template button then the download value disappear. enter image description here.

enter image description here

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.

VDWWD
  • 35,079
  • 22
  • 62
  • 79
Amit Patel
  • 69
  • 9

1 Answers1

1

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.

VDWWD
  • 35,079
  • 22
  • 62
  • 79
  • thank you so much I was using http://stackoverflow.com/questions/5731224/calling-javascript-function-from-codebehind `Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","MyFunction()",true);` – Amit Patel Jan 27 '17 at 20:52
  • You're welcome. But you could also set the text of the button in the same method in code behind if you know the value of `ddnamevalue` there. – VDWWD Jan 27 '17 at 20:54