【发布时间】:2014-08-06 17:11:45
【问题描述】:
控制器中的代码:此操作从数据库中获取数据并使用此数据填充(类列表)
public ActionResult GetClassListForTeacher()
{
List<string> classlist = null;
ProfileEntities pe= new ProfileEntities();
string uID = HttpContext.Session["NID"].ToString();
int year = 2011;
//int year = DateTime.Now.Year;
int session = set_session();
if (session == 1)//teacher
{
classlist = (from c in pe.CLASSES
join lc in pe.LESSON_CARDS
on new { EDUSTG_CODE = c.EDUSTG_CODE, STATISTICAL_CODE = c.STATISTICAL_CODE, FIRST_YEAR = c.FIRST_YEAR,
GRD_CODE = c.GRD_CODE , OCF_CODE = c.OCF_CODE , CLS_SN = c.CLS_SN}
equals new { EDUSTG_CODE = lc.EDUSTG_CODE, STATISTICAL_CODE = lc.STATISTICAL_CODE_BELONGS_TO, FIRST_YEAR = lc.FIRST_YEAR,
GRD_CODE = lc.GRD_CODE , OCF_CODE = lc.OCF_CODE_BELONGS_TO , CLS_SN = lc.CLS_SN}
where (lc.NID == uID && lc.FIRST_YEAR_HAVE == year)
select c.NAME
).ToList();
}
if (session == 2)//student
{}
return Json(classlist, JsonRequestBehavior.AllowGet);
}
这个代码在视图中
<div class="dialog-fluid" id="MoreOptionModal" style="display: none; height: 300px; overflow: scroll;" title="Options">
<div class="row-fluid">
<div class="block-fluid">
<div class="row-form">
<div class="span12">
<table style="border: 0;">
<tr>
<td style="border: 0;">@Html.RadioButton("type","Friendes",false,new { id = "Friendes"})</td>
<td style="border: 0;"><label>All Friendes</label></td>
</tr>
<tr>
<td style="border: 0;">@Html.RadioButton("type","Teachers",false,new { id = "Teachers"})</td>
<td style="border: 0;"><label>All Teachers As Friends</label></td>
</tr>
<tr>
<td style="border: 0;"></td>
<td style="border: 0;">@Html.RadioButton("type","Same School",false,new { id = "Same_School" })</td>
<td style="border: 0;"><label>Same School</label></td>
</tr>
<tr>
<td style="border: 0;"></td>
<td style="border: 0;">@Html.RadioButton("type","Other School",false,new { id = "Other_Schools"})</td>
<td style="border: 0;"><label>Other School</label></td>
</tr>
<tr>
<td style="border: 0;">@Html.RadioButton("type","Schoolmates",false,new { id = "Schoolmates"})</td>
<td style="border: 0;"><label>All Students As Friends</label></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
我想在调用(Schoolmates)的最后一个单选按钮之后添加单选按钮列表 这是js中的代码
$("#MoreOptionModal").dialog({
autoOpen: false,
modal: true,
});
$("#options").live("click", function () {
debugger;
$("#MoreOptionModal").dialog('open');
$.ajax({
url: "/Mail/GetClassListForTeacher",
type: "POST",
datatype: "json",
data: { },
traditional: true,
success: function (result) {
}
});
});
问题是我的视图中已经有模型,我从数据库中检索数据,我想向它展示我的视图
【问题讨论】:
-
您必须通过 JavaScript 添加元素,例如使用 jquery append 方法。你已经把脚本代码放在Ajax请求的成功函数中了。
-
好的,我明白你在说什么,但在代码中如何@CarlosCorralCarvajal
标签: javascript jquery asp.net-mvc radio-button