Changing asp.net Label text in JQuery -


i have label , want change value jquery. new value assigned label , changed default value automatically. means new value lost post on button. when alert message displayed, new value assigned label, on clicking on alert msg, default value again restored. below code.

       $(document).ready(function () {             $("#btnsave").click(function () {                 var value = $("#txtname").val().trim();                 if (value == '') {                      $('#<%=hfisvalid.clientid %>').html("false");               //    $('#<%=hfisvalid.clientid %>').text("false");               //    $('#hfisvalid%>').text("false");               //  above 3 statements works simailarly                     alert('name requried');               // here when alert comes new value displayed, after clicking ok on               // alert message, default value restored again.                    return;                 }             });         }); 

thanks in advance...

when you're doing postback, you're assigning default values once again in page_load() etc.

try to, instead of

return;

add

return false;

this prevent normal button onclick() behaviour courses postback


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -