查看MVC4中未更新的值 [英] View values not updating in MVC4
问题描述
到目前为止我做了什么,
第1步:
a)创建了一个视图课程并添加了一些文本框,下拉列表和动作链接。
Hi,
What I have did so far,
Step 1:
a) Created a view Course and added some textboxes, dropdowns and an actionlink.
@Html.ActionLink("Search", "Search", "Search", new { id = "new-value-link", })
b)然后添加了一个div,用于打开部分视图作为弹出窗口
b) Then added a div, which is used to open a partial view as popup
<div id="dialog">
</div>
c)在actionlink上单击,通过jquery打开部分视图作为弹出窗口
c) On actionlink click, opened a partial view as popup through jquery
<script type="text/Javascript">
$(document).ready(function () {
$('#new-value-link').click(function () {
var href = this.href;
$('#dialog').dialog({
modal: true,
height: 480,
width: 580,
open: function (event, ui) {
$(this).load(href, function (result) {
$('#idSearchlbx').click(function () {
var retCourseId = $("#idSearchlbx option:selected").val();
$('#dialog').dialog('close');
$.ajax({
type: "POST",
url: "/Course/Course/",
data: { "retCourseId": retCourseId },
dataType: "html",
success: function (evt) {
},
error: function (req, status, error) {
alert("Error!Occured");
}
});
});
});
}
});
return false;
});
});
</script>
d)在局部视图中,
d) In partial view,
@Html.ListBoxFor(m => m.SelectedId, new SelectList(Model.Groups, "Value", "Text"), new { id = "idSearchlbx", style = "height:365px;width:550px;" })
在列表框项目上单击,所选项目值的ID将在父视图中传递给action-controller(通过上面提到的jquery)。在该操作中,我获取与该id相对应的详细信息并将详细信息作为模型对象返回。 (比如返回视图(模型))。但是这些值不会反映在视图中。
On listbox item click, ID of selected item value will be passed to action- controller in parent view (through above mentioned jquery). In that action, I have fetch the details corresponding to that id and return the details as model object. (like return View(model)).But the values are not reflected in view.
推荐答案
( document )。ready( function (){
(document).ready(function () {
(' #new-value-link')。click( function (){
var href = 此 .href;
('#new-value-link').click(function () { var href = this.href;
(' #dialog')。dialog({
modal: true ,
height: 480 ,
宽度: 580 ,
open: function (event,ui){
('#dialog').dialog({ modal: true, height: 480, width: 580, open: function (event, ui) {
这篇关于查看MVC4中未更新的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!