2013-12-19 3 views
0

Html.BeginForm전달 입력 매개 변수

를이 지금까지 시도 무엇입니까 사용할 때 나는이 elemetry 매우 실감 그러나 나는 컨트롤러 방법에 텍스트 상자 값을 전달하고 싶은

cshtml

@using (Html.BeginForm("GetPassword", "Home")) 
{ 
    <div id="panEmailForgotPassword"> 
     <h3 style="margin: 0;"> 
      Please enter your email address</h3> 
     <br /> 
     <table style="width: 57%; padding-bottom: 10px; height: 126px;"> 
      <tr> 
       <td> 
        <label style="width: 110px;"> 
         Email address:</label> 
       </td> 
       <td> 
        @Html.TextBoxFor(m => m.EmailForgotPassword, new { name = "txtEmailForgotPassword" }) 
       </td> 
      </tr> 

제어 방법

[HttpPost] 
    public ActionResult GetPassword(string txtEmailForgotPassword) 
    { 
     ViewModel model = new ViewModel(); 

     model.VerifyUserExists(txtEmailForgotPassword); 
     return View(model); 
    } 

txtEmailForgotPassword는 null 값을 반환합니다.

어떻게하면 제대로 할 수 있습니까?

차라리 당신이

[HttpPost] 
    public ActionResult GetPassword(YourModel yourmodel) 
    { 
     ViewModel model = new ViewModel(); 

     model.VerifyUserExists(yourmodel.EmailForgotPassword); 
     return View(model); 
    } 

답변

3

아리안

. 그레이트. 감사. 아직도 mvc와 그립에 와서
+0

멋진 뷰에서 전체 모델을 전달할 수 있습니다, 단일 문자열 paramater를 전달할 필요가 있다고 생각하지 말아 – Arianule

+0

나중에 문제가되지 않습니다. 모두가 아무것도에서 시작하지 않는다;) –

+0

그러나 나는 우리 팀 hahaha에 대한 첫 번째 테스트를 잃을 팀에게 물어, 하나의 부탁을 원한다;) –