-1

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);
dumbass
27.2k4 gold badges43 silver badges77 bronze badges
asked Dec 22, 2011 at 5:55
3
  • Is the function being fired at all? Is that code working? Try: ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(),"load","alert('Hello world';", true); Commented Dec 22, 2011 at 5:59
  • if/else without curly braces is asking for trouble...not sure what "onsubmit:" is supposed to do after a return statement...and you will need to provide a more specific question than "what is wrong". Commented Dec 22, 2011 at 5:59
  • Please explain exactly what you're trying to achieve here. Apart from your syntactical issues, it looks like you're trying to prevent form submission? Commented Dec 22, 2011 at 6:11

3 Answers 3

2

Remove the line after returning true and false

 onsubmit: true;
 onsubmit: false;
answered Dec 22, 2011 at 6:00
Sign up to request clarification or add additional context in comments.

Comments

2

Remove the lines:

onsubmit: true;

and

onsubmit: false;

That's not valid Javascript.

answered Dec 22, 2011 at 6:00

Comments

2

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.

answered Dec 22, 2011 at 6:04

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.