none
ASP.NET Web Forms FAQ: Bagaimana menggunakan Submit Form? RRS feed

  • Diskusi Umum

  • Page1.aspx

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

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

    <script runat="server"> 

    </script> 

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

    <head> 

    <script language="javascript"> 

        function CopyTextToHiddenField() 

        { 

            var textbox1Value = document.getElementById("<%=TextBox1.ClientID%>").value; 

            document.forms[1].document.getElementById("Hidden1").value = textbox1Value; 

        } 

    </script> 

    </head> 

    <body> 

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

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 

        </form> 

        <form name="SubmittedForm" action="page2.aspx" method="post"> 

        <input id="Submit1" type="submit" value="submit" onclick="CopyTextToHiddenField()" /> 

        <input name="Hidden1" type="hidden" /> 

        </form> 

    </body> 

    </html>

     

     

    Page 2.aspx

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

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

     

    <script runat="server"> 

     

        protected void Page_Load(object sender, EventArgs e) 

        { 

            Response.Write(Request.Form["Hidden1"]); 

        } 

    </script> 

     

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

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

    </head> 

    <body> 

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

        <div> 

        </div> 

        </form> 

    </body> 

            </html>

     

    Thread terkait:

    http://forums.asp.net/p/1257184/2339923.aspx
    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Kamis, 18 Agustus 2011 03.18
    Moderator