button handler problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie

    button handler problem

    i have a c# asp.net webform that has a "Close" button. When the user clicks
    the Close button, a message box saying "do u want to save to database...?".
    the problem is that the statements inside the Close function are not being
    executed. how can i save the data in the webform to the database? can i show
    a message box without using javascript? can i call a function defined in the
    code behind from within javascript? thanks in advance.

    code behind:
    private void Page_Load(objec t sender, System.EventArg s e)
    {
    //btnClose.Attrib utes.Add("OnCli ck", "javascript:Clo se()");
    btnClose.Attrib utes.Add("OnMou seDown", "javascript:Clo se()");
    .......
    }

    private void btnClose_Click( object sender, System.EventArg s e)
    {
    if (txtClose.Text == "1")
    {

    InsertToDatabas e();
    }
    Response.Redire ct("taskOrderSu mmary.aspx");
    }

    html code in aspx page:
    <script type="text/javascript">
    function Close(){
    var agree=confirm(" Do you wish to save changes?");
    if (agree)
    {
    document.Form1. txtClose.value = 1 ;
    }
    else
    {
    document.Form1. txtClose.value = 0 ;
    }
    }

Working...