Within the C# backend code for a website, I have implemented code that presents users with a confirmation message detailing the data they are about to submit. This message requires human-confirmation that the information displayed is accurate.
The challenge lies in accessing the outcome of the confirm
function as my code is executed on the server-side in C#, not on the client-side in JavaScript. Depending on whether the user clicks OK or Cancel, my C# logic needs to branch into different paths.
I am currently working on an outdated application that has been around for 13 years without much modification. Therefore, I am unable to make any significant changes to the overall design of the application.
ClientScript.RegisterStartupScript(this.GetType(), "InvalidEntrySubTypeAlert", "confirm('" +
"Are you sure you want to create the following deal?\n" +
"\nDeal ID :\t\t\t" + nDealID +
"\nCompany Name :\t\t" + txtCompanyName.Text +
"\nEntry Subject :\t\t" + txtEntrySubject.Text +
"\nBusiness Lead :\t\t" + ddlBusinessLead.SelectedItem.Text +
"\nLicense Status :\t\t" + ddlLicenseStatus.SelectedItem.Text +
"\nEffective Date :\t\t" + string.Format("{0:MM/dd/yyyy}", calEffectiveDate.SelectedDate) +
"\nExpiration Date :\t\t" + string.Format("{0:MM/dd/yyyy}", calExpirationDate.SelectedDate) +
"\nLicense Location :\t\t" + txtLicenseLocation.Text +
"\nEntry Sub Type :\t\t" + ddlEntrySubType.SelectedItem.Text.Split(' ')[0]
+ "');", true);