Submit button and Javascript
I have a Submit button with code behind that evaluates stuff in c#, the problem is that I also want to add a function in javascript that asks "This file already exists, do you want to replace it?
So my question is how can I trigger both? 开发者_运维技巧
OnClick="myC#mehod" and also OnClientClick = return (some javascript);
Can I do this?...
deleteBtn.Attributes["onClick"] =
"return confirm('This file already exists, do you want to replace it?');"
Updated for clarification;
<asp:Button ID="btnReplace" runat="server" onclick="btnReplace_Click" Text="Button" OnClientClick="return confirm('This file already exists, do you want to replace it?');" />
protected void btnReplace_Click(object sender, EventArgs e)
{
//Replace the File
}
OnClientClick="return confirm('This file already exists, do you want to replace it?');"
OnClientClick = "if(!confirm('This file already exists, do you want to replace it?')) return false;"
this is more safer than return
direct
精彩评论