0
我需要以html格式創建電子郵件的主體。在HistoryController中,我定義了一個metod,它返回一個對象(Course),這些屬性將用於打包正文,正如我所說的那樣。我不知道如何獲得視圖中的對象。我已經看到了使用ActionResult的metod,但我不提供它只是像創建電子郵件的輔助工作。從控制器中獲取對象MVC
我明白了。
HistoryController
public static CURSO courseSelected = new CURSO();
public static CURSO courseSel()
{
courseSelected.Name = "Physics";
return courseSelected;//cursoSelected del tipo CURSO
}
查看
@model Project.Models.Course
@{
var courseSel = Project.Models.HistoryController.courseSel();
}
<fieldset class="fHorizontalCenter">
<label style="font-size:18px">Welcome to course of </label><label>@courseSel.Name</label>< br />
</fieldset>
,但我不能使用去變量的數據,它總是打印此
歡迎@courseSel當然。名稱
你如何訪問該視圖? –
以及爲什麼模型命名空間中的控制器? –
您查看有.cshtml擴展名?視圖中的所有標記是正確打開和關閉的? –