การสร้าง Web Form Method Post  ของ  ASP.NET คล้ายๆกับ Form method POST ของ PHP

หน้า Form Post

    <form method="post">

        <%for (int i = 0; i < 10; i++)
            {%>
               <input name="txtStudentCode" type="text" value="" />

          <%  } %>
       
       <asp:Button ID="btnSend" runat="server" Text="Send" PostbackUrl="StudentListAddDo.aspx" />
    </form>

หน้ารับค่า Post StudentListAddDo.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class StudentListAddDo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // String s=Request.QueryString.
        //Response.Write(Request.Form["txtStudentCode"]);
        string[] sSTUDENTCODE = Request.Form["txtStudentCode"].ToString().Split(',');
        for (int i = 0; i < sSTUDENTCODE.Length; i++)
        {
            Response.Write("<br/>" + sSTUDENTCODE[i]);
        }

    }
}

 

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.