-1
세부 정보를 제공 할 때 새 값을 할당 할 때마다 값이 인쇄되지만 텍스트 상자 자체에서 제공하는 값과 동일한 값을 인쇄하려고합니다. . 나는 이것을 위해 [httppost]와 [httpGet] 명령을 사용하고있다. 출력을 Visual Studio의 동일한 텍스트 상자에 표시합니다.
@{
ViewBag.Title = "LoginPage";
}
<h1>LoginPage</h1>
<form method="post" action="/Home/LoginPage" >
<table>
<tr>
<td>First Name : </td>
<td><input type="text" id="txt.Fname" name="F_FIRSTNAME" class="form-control"/> </td>
</tr>
<tr>
<td> Last Name : </td>
<td><input type="text" id="txt_LNAME" name="L_LastName" class="form-control"/></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" id="txt_Password" name="P_PASSWORD" class="form-control" /> </td>
</tr>
<tr>
<td>Email ID : </td>
<td><input type="email" id="txt_emailid" name="E_EmailID" class="form-control" /> </td>
</tr>
<tr>
<td><input type="submit" id="txt_Enter" name="Enter" class="btn-primary" /></td>
</tr>
</table>
</form>
@{
if(IsPost==true)
{
string name1 = Request["F_FIRSTNAME"];
if(!string.IsNullOrEmpty(name1))
{
<h2 style=" color:aquamarine;" > <input type="text" value="@name1" /> </h2>
}
string name2 = Request["L_LASTNAME"];
if (!string.IsNullOrEmpty(name2))
{
<h2 style="color:blue;"> <input type="text" value="@name2" /> </h2>
}
string name3 = Request["P_PASSWORD"];
if (!string.IsNullOrEmpty(name3))
{
<h2 style="color:blue;"> <input type="text" value="@name3" /> </h2>
}
string name4 = Request["E_EMAILID"];
if (!string.IsNullOrEmpty(name4))
{
<h2 style="color:blue;"> <input type="text" value="@name4" /></h2>
}
else
{
<h5>This is a get request </h5>
}
}
}
및 컨트롤러
가 :using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication3.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
public ActionResult LoginPage()
{
return View();
}
[HttpPost]
public ActionResult AfterLoginPage(string F_FIRSTNAME, stringL_LASTNAME, string P_PASSWORD, string E_EMAILID)
{
return View("LoginPage");
}
}
}
[당신이 있지만 자격 증명이 내가 만든 별도의 텍스트 상자에 표시되어 볼 수 있듯이 내가 원하는에 대한보기 페이지에서
나는이 코드를 동일한 텍스트 상자에 표시] [여기에 이미지 설명을 입력하십시오] 1
나는 그것이 복잡하다고 생각합니다. Simpy는보기 모델을 사용하고 양식 내에서'TextBoxFor' 메소드를 사용합니다. 해당 if-else 조건부 표시가 필요 없습니다. – Shyju
예, 사용자가 정보를 입력해야하는 경우 ViewBag 또는 데이터보기를 사용하려면 어떻게해야합니까? – vysnav05