An Office service that supports add-ins to interact with objects in Office client applications.
Hi @RD,
Based on your code, are you passing confirm_closingValue to c#?
But the naming of your "input" is messy, named confirmValue, and the next line becomes confirm_closingValue.
I think you should unify, you can refer to the code below.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type = "text/javascript">
function confirm_closing() {
var confirm_closingValue = document.createElement("INPUT");
confirm_closingValue.name = "confirm_closingValue";
if (confirm("Do you want to accept the closing?")) {
confirm_closingValue.value = "CONFIRM";
} else {
confirm_closingValue.value = "CANCEL";
}
document.forms[0].appendChild(confirm_closingValue);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnConfirm" runat="server" OnClick="OnConfirm" Text="Confirm" OnClientClick="confirm_closing()"/>
</form>
</body>
</html>
public void OnConfirm(object sender, EventArgs e)
{
string confirmValue = Request.Form["confirm_closingValue"];
if (confirmValue == "CONFIRM")
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked CONFIRM!')", true);
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked CANCEL!')", true);
}
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.