<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ControlsExample2.aspx.cs" Inherits="FormControls.ControlsExample2" %>

 

<!DOCTYPE html>

 

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

<head id="Head1" runat="server">

    <title>HFC Example</title>

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

        function Validate(flag) {

            var text;

            text = document.getElementById("txtInput").value;

 

            if (text == "") {

                // Write a message into the ASP Label

                document.getElementById("lblDisplay").innerHTML = "Please enter a value in the textbox.";

            }

            else {

                // Determine which button was clicked and place a flag for the server to use in processing

                if (flag == 1) {

                    document.getElementById("hdnFlag").value = "uppercase";

                }

                else if (flag == 2) {

                    document.getElementById("hdnFlag").value = "lowercase";

                }

 

                // submit the form for server processing

                document.getElementById("form1").submit();

            }

 

        }

    </script>

</head>

<body>

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

    <div>

        <h3>HTML button control intercepted for client-side processing with submit to server-side for further processing <br />

            Use of an HTML hidden control to pass state information from the client to the server side </h3>

 

        <asp:Label ID="lblDisplay" runat="server" Text="Enter a string:"

            ForeColor="#CC3300"></asp:Label>

        <br />

        <asp:TextBox id="txtInput" runat="server"></asp:TextBox>

        <br />

        <br />

       

        <input id="btnHFC1" value="Submit for CS Validate and Return UpperCase"

               type="button" onclick="Validate(1);" /> <br />

 

        <input id="btnHFC2" value="Submit for CS Validate and Return LowerCase"

               type="button" onclick="Validate(2);" />

       

       

        <input id="hdnFlag" name="hdnFlag" type="hidden" />

   

    </div>

    </form>

</body>

</html>