C# | ASP.NET/ASP.NET
ASP.NET Code Behind에서 Post로 값 넘기기
bboks.net
2011. 6. 16. 16:38
일반적으로 aspx에서 form 태그를 써서 값을 넘겨도 되지만 부득이하게 코드비하인드에서 POST로 값을 넘겨야 할 경우가 발생한다.
아래의 코드를 이용하면 한방에 해결
private void submitForm(string url, string mallId, string mallNo, string orderNo)
{
System.Web.HttpContext.Current.Response.Write("<form name='newForm' method=post action='" + url + "'>");
{
System.Web.HttpContext.Current.Response.Write("<form name='newForm' method=post action='" + url + "'>");
System.Web.HttpContext.Current.Response.Write(string.Format("<input
type=hidden name=\"mallId\" value=\"{0}\">", mallId));
System.Web.HttpContext.Current.Response.Write(string.Format("<input
type=hidden name=\"mallNo\" value=\"{0}\">", mallNo));
System.Web.HttpContext.Current.Response.Write(string.Format("<input
type=hidden name=\"orderNo\" value=\"{0}\">", orderNo));
System.Web.HttpContext.Current.Response.Write("</form>");
System.Web.HttpContext.Current.Response.Write("</body>");
Response.Write("<SCRIPT LANGUAGE='JavaScript'>document.forms[0].submit();</SCRIPT>");System.Web.HttpContext.Current.Response.Write("</body>");
}
[출처] POST through code behind in asp.net