2012-12-11 38 views
0

我有問題從視圖調用控制器的方法。MVC3從彈出窗口調用控制器方法

SendVotingPanel.cshtml

@model EmailTemplete.Models.SendVotingEmail 

@{ 
    ViewBag.Title = "SendVotingPanel"; 
} 
<h2>SendVotingPanel</h2> 
    <meta charset="utf-8" /> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script> 
<script type="text/javascript"` src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script> 
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
<link rel="stylesheet" href="/resources/demos/style.css" /> 

<script type="text/javascript"> 

    function Send() { 
     $(function() { 
      $("#dialog").dialog(); 
     }); 
    }; 
</script> 

<input type="button" value="submit" id="openpopup" onclick="Send();"/> 
@using (Html.BeginForm()) 
{ 
    <div style="display:none" id="dialog"> 

     <div class="editor-label"> 
      @Html.LabelFor(model => model.ContactEmail) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.ContactEmail) 
      @Html.ValidationMessageFor(model => model.ContactEmail) 
     </div> 

     <div class="editor-label"> 
      @Html.LabelFor(model => model.Subject) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.Subject) 
      @Html.ValidationMessageFor(model => model.Subject) 
     </div> 

     <div class="editor-label"> 
      @Html.LabelFor(model => model.Message) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.Message) 
      @Html.ValidationMessageFor(model => model.Message) 
     </div> 
        <br /> 
     <p> 
      <input type="submit" value="Save"/> 
     </p> 
</div> 
} 

控制器

public ActionResult SendVotingPanel() 
    { 
     return View(); 
    } 

    [HttpPost] 
    public ActionResult SendVotingPanel(Models.SendVotingEmail model) 
    { 
     return View(model); 
    } 

當我openpopup按鈕,然後點擊一個彈出窗口中顯示出來。當我用一些數據填充所有文本框並單擊按鈕時,我無法調用方法SendVotingPanel。 我的代碼是否有任何改變?

回答

1

嘗試改變:

@using (Html.BeginForm()) 
{ 
    <div style="display:none" id="dialog"> 
     ... 
    </div> 
} 

要:

<div style="display:none" id="dialog"> 
    @using (Html.BeginForm()) 
    { 
     ... 
    } 
</div> 
+0

感謝答覆偉大的工作。 – Amol

相關問題