开发者

Submit button and Javascript

开发者 https://www.devze.com 2023-03-15 19:06 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消