0
我彈出局部視圖:彈出到控制器
@using StudiModel
@model StudiModel.StudiCommentsPopup
@{
Layout = "~/Views/Shared/_TopNavLayout.cshtml";
}
@Model.MessageUser
foreach (var item in Model.CommentsList)
{
@item.CommentText
}
@using (Html.BeginForm())
{
<div class="input-control textarea" data-role="input-control" style="width: 85%">
@Html.TextArea("Message", new { @placeholder = "Add a comment", id = "Comment", style = "width:720px" })
</div>
<input type="button" id="postComment" value="Add a Comment" />
@Html.HiddenFor(Model => Model.PMessageId)//Why can't I put this here, because I want to pass the text and this id to controller
}
我需要一個jQuery後值到控制器,並關閉自身單擊Add按鈕時,以及如何通過兩個值到jQuery的? 感謝
我的控制器:
[HttpPost]
//jquery shoul get me two values, id and text box value
public ActionResult PostComments(string parentMsgId,string Comment)
{
StudiMessageDetails comment = new StudiMessageDetails();
var balObject = new BusinessLogic();
//comment.UserId = (StudiUserInfoViewModel)Session["UserInfo"].
comment.MessageId = parentMsgId;
comment.CommentText = Comment;
comment.UserId = ((StudiUserInfoViewModel)Session["UserInfo"]).UserId;
var message = balObject.AddComment(comment).Message;
return View();
}
嗯,我需要在我的局部視圖一個jQuery的價值觀傳遞給我controller..Its淨.. 要打開我使用了彈出局部視圖:
<span class="list-subtitle"><span class="place-right icon-flag-2 fg-red smaller" onclick="ShowMessage('@item.MessageId');">23
</span>
和jQuery:
<script>
function ShowMessage(msgid) {
$.Dialog({
overlay: false,
shadow: true,
flat: false,
title: 'Studidesk - Conversations',
content: '',
onShow: function (_dialog) {
var html = [
'<iframe width="800" height="480" src="/Channel/Comments?msgid=' + msgid + '" frameborder="0" allowfullscreen></iframe>'
].join("");
$.Dialog.content(html);
}
});
}
這不是所有的jQuery。 (是.NET/C#?)你應該添加適當的標籤 – royhowie 2015-02-11 05:54:51
我很困惑 - 你說你想使用jquery將值傳遞給你的控制器,但你有一個窗體中的視圖 - 你想要哪種方法使用?這個表格可能會更容易,因爲你已經有了代碼! – markpsmith 2015-02-11 10:00:19