我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 – Golda
您的代碼似乎沒有任何異常其正確的問題必須是不同的 – Rahul