Modal Popup Extender, AJAX Tool Kit, Validation Controls ASP.NET





I am using Modal popup Extender in my project which after click save button appears and takes Reason for doing that action as an input. I am using a text box labelling Reason for change; if that box is empty I am telling my transaction to roll back. So to make changes appear in database user has to fill the reason. I wanted to validate that using required validation control of Asp.net but it was firing the validation on parent page so it was not showing me modal popup. Then I used JavaScript to validate that box and it worked. I am using JavaScript behind my modal popup panel OK button which checks if reason to change is empty then show warning and do not proceed until unless user provides the reason for change.

<script type=”text/javascript”>

function ValidateReason()

{

if(document.getElementById(‘<%=txtChangeReason.ClientID%>’).value==“”)

{

alert(“Please enter reason for change!”);

window.event.returnValue = false;

return false;

}

return true;

}

</script>

window.event.returnValue = false; this line cancels all event without this line modal popup was hiding itself without validation. Please leave your comments or anyother way around.




  1. This is best one article so far I have read online. I would like to appreciate you for making it very simple and easy. I have found another nice post related to this post over the internet which also explained very well. For more details you may check it by visiting this url…

    Thanks