I have a jQuery script in WebForms that I'm trying to get to display a message on a button click event. I have the script in my .aspx file and I'm calling it in code-behind. The issue is how do I redirect if a user clicks the confirm and not the cancel button?
.ASPX Script:
<script type="text/javascript">
$(window).unload(function () {
CloseWindow();
})
//var newEmployeeDetail = document.getElementById(hfNe)
function confirmAppointEmployee() {
debugger;
Messi.ask("Employee appointed successfully",
function (val) {
if (val == false) {
$("[id*=Cancel]").click();
}
else {
$("[id*=Confirm]").click();
}
}, {
buttons: [{ id: '0', label: 'Confirm', val: true, 'class': 'btn-primary' }, { id: '0', label: 'Cancel', val: false }]
});
}
</script>
Code Behind:
ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script>confirmQuickAppointEmployee()</script>");
The below code is the string that needs to be called to redirect the user.
private string PersonalInformationDetailUrl = Company.Framework.SmartNavigationPersonnel.SmartNavigation.GetUrlByPageName(Company.Framework.SmartNavigationPersonnel.SmartNavigation.PageNameList.PersonalInformationDetail) + "?AllowAddOption=true&AllowDeleteOption=true&RefreshMenuPage=true";
I have tried the below method but both the cancel and confirm button do the same thing.
var confirm = "$(document).ready(function(){ new Messi('Employee appointed successfully', " +
"{title: 'Title', buttons: [{id: 0, label: 'Close', val: 'false'},{id: 0, label: 'Confirm', val: 'true'}], " +
"callback: function(val) { window.location.href = '" + Functions.FixClientUrl(PersonalInformationDetailUrl) + "' }}); });";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "confirm", confirm, true);
from Messi jQuery Confirmation Box Redirect
No comments:
Post a Comment