2011-11-06 16 views
2

私は2つの送信ボタンを使用します。私はここにそれを作る方法を見出した(asp.netのmvc3のaplicattion)複数送信ボタン(asp.net mvc3)

http://blog.maartenballiauw.be/post/2009/11/26/Supporting-multiple-submit-buttons-on-an-ASPNET-MVC-view.aspx

これはMultiButtonAttributeクラスを置きますか?コントローラーで?

これを行うには、おそらく最も簡単な方法です。

+0

を含むアプリケーションの任意の場所に追加することができます。 –

+0

必要に応じて、これを使用する必要はありません。 2番目のボタンにフォームの変数が必要ない場合(たとえば、「新しい行の作成」ボタン)、2番目のボタンの2番目のフォームのみを作成できます。これにより、はるかに簡単になります。 –

+0

ボタンを使用すると、このRedicttoactionにどのように追加できますか?私はボタンを押すと、私は反対側に行くのですか? – user1031034

答えて

1

あなたがいる限り、コントローラのために使用することに言及があるとしてどこにでもクラスを置くことができるPLCフォルダ

1
**//model** 
    public class input_element 
     { 
     public string Btn { get; set; } 
     } 

**//views** 
    @using (Html.BeginForm()) 
    { 
      <button type="submit" name="btn" value="verify"> 
      Verify data</button> 
      <button type="submit" name="btn" value="save"> 
      Save data</button>  
      <button type="submit" name="btn" value="redirect"> 
       Redirect</button> 
    } 

**//controller** 

    public ActionResult About() 
     { 
      ViewBag.Message = "Your app description page."; 
      return View(); 
     } 

     [HttpPost] 
     public ActionResult About(input_element model) 
     { 
       if (model.Btn == "verify") 
       { 
       // the Verify button was clicked 
       } 
       else if (model.Btn == "save") 
       { 
       // the Save button was clicked 
       } 
       else if (model.Btn == "redirect") 
       { 
       // the Redirect button was clicked 
       } 
       return View(); 
     } 
+1

あなたはOPがここで尋ねた質問に答えていません。 –

関連する問題