简体   繁体   English

确认消息框asp.net

[英]Confirm Message Box asp.net

How to store Data to Database after the confirmation button if you click Yes the data will be save to database if cancel nothing will happen. 如果单击“是”,如何在确认按钮后如何将数据存储到数据库,如果取消则什么也不会发生,数据将保存到数据库。

Here's the code 这是代码

Page.ClientScript.RegisterStartupScript(
    this.GetType(), 
    "ConfirmBox", 
    "if(confirm('Are you sure?') == true){window.location='../MyReservation.aspx';};", 
     true);

it only directs to another page but does not save the data to database. 它仅定向到另一个页面,而不将数据保存到数据库。

Thanks in advance to those will answer my question. 在此先感谢那些会回答我的问题。

Setting window.location just loads a new page. 设置window.location只会加载一个新页面。

I assume you have a form with the data to save, use jQuery to submit that form: $('#myForm').submit() instead of setting window.location . 我假设您有一个要保存数据的表单,使用jQuery 提交该表单: $('#myForm').submit()而不是设置window.location

Store the data in session state, and in the Load method of MyReservation.aspx, retrieve it from session and store in database. 以会话状态存储数据,并在MyReservation.aspx的Load方法中,从会话中检索数据并将其存储在数据库中。 Transfer to new page instead of loading a new window. 转移到新页面,而不是加载新窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM