【发布时间】:2014-03-14 05:29:39
【问题描述】:
我在 viewBag 中有一个用户 ID 我想在我的对话框中访问 ViewBag
<script>
$(function () {
$("#dialog").dialog({
autoOpen: false,
modal: true,
width: 339,
overlay: {
backgroundColor: 'red',
opacity: 0.5
},
show: {
effect: "blind",
duration: 500
},
hide: {
effect: "explode",
duration: 700
}
});
});
function OpenDialog()
{
$('#dialog').dialog("open");
}
</script>
<div id="open" onclick="OpenDialog();">Click To Open</div>
@ViewBag.UserID
<div id="dialog">
<table>
<tr>
<td>User ID</td>
<td>@ViewBag.UserID</td>
</tr>
<tr>
<td>Comments</td>
<td>@Html.TextArea("CommentsTextBox")</td>
</tr>
</table>
<div class="alignCenter">
<input type="submit" value="Add" />
<input type="button" value="Cancel" />
</div>
</div>
【问题讨论】:
-
您的问题/问题是什么?
-
当我打开 JQuery 对话框时
@ViewBag.UserID 显示空/空值。但外部 @ViewBag.UserID 显示正确的用户 ID -
您的代码似乎没有任何异常,正确的问题必须是不同的东西
-
除了空的 UserID 之外,对话框是否正确显示?
标签: jquery asp.net-mvc dialog viewbag