關於我

我的相片
用心思考、保持熱情,把工作上的經驗作分享與紀錄。希望能夠跟大家一起不斷的成長~

html元件 vs Asp元件onclick事件的不同

<%@ Page Language="C#" AutoEventWireup="true" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <%--JavaScript—%>
    <script type="text/javascript">
         function ClientSideScript() { alert('ClientSide!'); }
    </script>
    <%--Inline Code—%>
    <script language="CS" runat="server">
         protected void ServerSideScript(object sender, EventArgs e) { Response.Write("alert('ServerSide!');"); }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input type="button" id="Button2" runat="server" value="html_button" onserverclick="ServerSideScript" onclick="ClientSideScript();"      />
            <asp:button          id="Button1" runat="server" Text="aspx_button"  OnClick="ServerSideScript"       OnClientClick="ClientSideScript()" />
        </div>
    </form>
</body>
</html>

可比較上方asp元件與html元件的差異..

ServerSide:OnClick
ClientSide:OnClientClick

ServerSide:onserverclick
ClientSide:onclick

沒有留言:

張貼留言