0
我想在text_changed事件上有一個確認消息並在ok上執行不同的代碼集並取消。幫我看看這些代碼在代碼後面執行不同的代碼在確認好並取消
<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 save data?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
代碼隱藏
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
// TextBox1.Attributes.Add("OnClientClick", "Confirm()");
string confirmValue = Request.Form["confirm_value"];
if (confirmValue == "Yes")
{
//Your logic for OK button
}
else
{
//Your logic for cancel button
}
}
public void OnConfirm(object sender, EventArgs e)
{
}
都成了這個樣子,但我想這樣做,而無需使用按鈕,我想使用文本框只
你在哪裏打電話給你的JS功能? – geedubb
請參閱相關修改 –
@geedubb請幫助我 –