<%@ Page Language="C#" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Example: Client/Server Processing with No CodeBehind</title>

    <script language="C#" runat="server">

        string msg = "";

        int count = 0;

       

        void Page_Load()

        {

            if (!IsPostBack)    // first page load

            {

                Session["Count"] = 0;

            }

            else                // page postback

            {

                count = (int)Session["Count"];

                count = count + 1;

                Session["Count"] = count;

                msg = "POSTBACK: ";

            }

        }

 

        protected void btnServerButton_Click(object sender, EventArgs e)

        {

            msg = msg + "You clicked the button that was processed on the server-side " +

                        count + " times.";

        }

    </script>

 

    <script language="javascript" type="text/javascript">

        var count = 0

 

        function WriteMessage() {

            count++;

            document.getElementById("dvDisplay").innerHTML = "You clicked the button that was processed on the client-side.<br />" +

                                                             "It was clicked " + count + " times."

        }

    </script>

</head>

<body bgcolor="#9999ff">

    <form id="form1" runat="server">

    <div>

        <h1>Client/Server Processing with No CodeBehind</h1>

        <br />

        <br />

        <div id="dvDisplay"> <%= msg %> </div>

        <br />

        <br />

        <input id="btnClientButton" value="Client Processed Button" type="button" onclick="WriteMessage();" style="width:217px;" />

        <br />

        <asp:Button ID="btnServerButton" Text="Server Processed Button" runat="server" OnClick="btnServerButton_Click" Width="217px" />

    </div>

    </form>

</body>

</html>