MVC中的部分视图,具有自己的模型和控制器

时间:2014-10-24 00:41:35

标签: c# asp.net-mvc

我正在使用自己的控制器制作部分视图,而模型I也想在我加载patial视图时传递一些数据,这是我的代码,请你检查一下,让我知道出了什么问题?

//Patial HTML Code
@model *******.Model.ViewModels.EmailViewModel

<fieldset class="emailForm_fn">
    <div class="left label width100">
        From</div>
    <div class="left">
        @Html.LabelFor(m => m.From, new { @class = "width300" })
    </div>   
</fieldset>


//Patial Contyroller Code
 public partial class EmailController : Controller
{
public ActionResult Initialize(string from)
        {
            var viewModel = new EmailViewModel()
            {
                Attachment = "",
                BCC = "",
                CC = "",
                Content = "",
                From = from,
                Subject = "",
                To = ""
            };
            return PartialView("~/Views/Shared/_email.cshtml",viewModel);
        }
}


//Codes for loading loading

@{ Html.RenderAction("Initialize", "Email", new { from = "Brezvani@ucm.com.au" }); }

0 个答案:

没有答案