0
我有一個確認的腳本彈出window.When我把這個在我們的aspx.cs頁面返回不同values.My腳本確認消息框返回錯誤值
<script type="text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to remove this employee from this group?")) {
confirm_value.value = "1";
} else {
confirm_value.value = "2";
}
document.forms[0].appendChild(confirm_value);
}
按鈕
<asp:Button ID="btnAdd" OnClientClick = "Confirm()" runat="server" ValidationGroup="1" onclick="btnAdd_Click" />
按鈕點擊功能
protected void btnAdd_Click(object sender, EventArgs e)
{
string confirmValue = Request.Form["confirm_value"];
if (confirmValue == "1")
{
//Do something
}
else
{
//Do something
}
}
第一次我點擊取消,然後我confirmvalue=="1"
,然後再次選擇ok,然後我的confirmvalue=="1,2"
代替2.它如何返回錯誤值。