<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function one() { if (false) { return true; } else { return false; } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return one();" onclick="Button1_Click" /> </div> </form> </body> </html>
protected void Button1_Click(object sender, EventArgs e) { Response.Write("This is Behind Code"); }
asp.net控件的onClientClick return 执行js函数,true通过则进入后端方法,false则不通过。
时间: 2024-10-06 06:37:45