How to get the response from Confirm box in the code behind

前端 未结 5 670
一向
一向 2021-01-19 05:20

I am new to asp.net/C# .I am trying to create a web application.

Below is my requirement.

I am trying to save a record on button click. Before saving the rec

5条回答
  •  感情败类
    2021-01-19 05:54

    You can do this in many ways:

    One is place a button on the page, make its display:none and when confirm is true, trigger its click with js.

    Like in aspx

    in client side make a js function for calling confirmation dialog box, like

    function ConfirmSave()
    {
       if(confirm('Record already exist.Do you want to proceed?')
       {
           jQuery("[ID$=btnSaveData]").click();
       }
    
    }
    

    in Code Behind

    Your code check in some event handler

    if (check == true)
    {            
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", 
          "ConfirmSave();", true);
    }
    

    bthSaveData click handler for saving data.

    protected void btnSaveData_Click(object sender, EventArgs e)
    {
     // Code for your saving.
    }
    

提交回复
热议问题