Phanindra Kumar
Phanindra Kumar

Reputation: 169

javascript calling

I'm calling this function from .cs file what is wrong

function Confirmcertificate(){

    var agree=confirm("Not sending any certificate");

    if(agree)

         return true;

         onsubmit: true;

    else
         return false;

          onsubmit: false;
}

.cs file coding is

ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), 
"load","Confirmcertificate();", true);

Upvotes: -1

Views: 163

Answers (3)

canon
canon

Reputation: 41715

Several problems:

function Confirmcertificate(){    
    if(confirm("Not sending any certificate"))
    { // you need braces to encapsulate multiple statements 
         onsubmit = true; // I imagine you meant to assign to some global variable...
         return true; // This must come after the assignment 
    } else {
         onsubmit = false; // this must come before return
         return false;    
    }
}

With those changes it should work.

Upvotes: 2

Adeel
Adeel

Reputation: 19238

Remove the line after returning true and false

  onsubmit: true;


  onsubmit: false;

Upvotes: 2

Abdullah Jibaly
Abdullah Jibaly

Reputation: 54820

Remove the lines:

onsubmit: true;

and

onsubmit: false;

That's not valid Javascript.

Upvotes: 2

Related Questions