2017-09-27 47 views
0

我試圖與引導彈出。在我的「NoteListPartial.cshtml」頁面;如果我點擊編輯按鈕,我想要彈出「Not.cshtml」打開。但是,當我點擊按鈕彈出出現,但我的頭與彈出出現過,但我不希望它是。自舉模式彈出設計問題有了頁眉

1 - 我稱之爲Detail.cshtml頁面上NoteListPartial.cshtml頁。

2-我Detail.cshtml代碼如下:

<div class="NoteList"> 

</div 

<script> 
    var projectid = @Model.ID; 
    $.ajax({ 
     method: "get", 
     url: '@Url.Action("NoteListPartial", "Project")', 
     data: {projectid:projectid}, 
     success: function(returningdata){ 
      $("div.NoteList").html(returningdata); 
     } 
    }); 
</script> 

3-和我的NoteListPartial.cshtml代碼如下:

@foreach (var item in Model) 
{ 
    <div class="item"> 
     <div class="item-head"> 
      <div class="item-details"> 
       <a class="item-name primary-link">@item.Name</a> 
       span class="item-status"> 
        <a href="@Url.Action("Note", "Project", new { ID = item.ID, ProjectID = item.ProjectID })" data-target="#NoteDetailModal" data-toggle="modal">EDIT</a> 
        <a href="@Url.Action("NoteDelete", "Project",new { ID=item.ID, ProjectID=item.ProjectID})">Delete</a> 
       </span> 
      </div> 
     </div> 
     <div class="item-body"> @item.Content </div> 
    </div> 
} 

<div class="modal fade" id="NoteDetailModal" tabindex="-1" role="dialog" aria-labelledby=""> 
    <div class="modal-dialog" role="document"> 
     <div class="modal-content"> 
      <!-- Content comes here. This code continues at Note.cshtml --> 
     </div> 
    </div> 
</div> 

4-和我的Note.cshtml代碼是如下,我希望「Not.cshtml」與打開彈出

<!-- Continuation of modal on page NoteListPartial.cshtml --> 

<div class="modal-header"> 
    <button type="button" class="close" data-dissmiss="modal" aria-label="Close"><span aria-hidden="true">x</span></button> 
    <h4 class="modal-title" id="myModalLabel">Edit Note</h4> 
</div> 
<form method="post" role="form"> 
    <div class="modal-body"> 
     <div class="form-group"> 
      <label>Title:</label> 
      <input type="text" name="Name" value="@Model.Name" /> 
     </div> 
     <div class="form-group"> 
      <label>Content:</label> 
      <textarea name="Content">@Model.Content</textarea> 
     </div> 
    </div> 
    <div class="modal-footer"> 
     <input type="submit" class="btn btn-default" value="Update" /> 
    </div> 
</form> 

當我運行該項目,並單擊Detail.cshtml編輯按鈕,彈出是開放,但我遇到了這樣的畫面: enter image description here

ProjectController.cs:

public ActionResult NoteListPartial(RaporModel Filter, int? ProjectID) 
{ 
    IEnumerable<tbl_ProjectNote> prjnote = Sabitler.Note.Where(d => d.ProjectID == ProjectID).OrderByDescending(d => d.ID); 
    int PageNo = Convert.ToInt32(Request.QueryString["Page"] ?? "1"); 
    int totalnumber = prjnote.Count(); 
    prjnote = prjnote.Skip((PageNo - 1) * Filter.SBGS).Take(Filter.SBGS); 
    ViewBag.Pagination = Functions.PageToGet(PageNo, totalnumber, Filter.SBGS, "", "active"); 
    return PartialView(prjnote.ToList()); 
} 

public ActionResult Note(RaporModel Filter, int? ID) 
{ 
var prjnote = db.tbl_ProjectNot.FirstOrDefault(d => d.ID == ID); 
if (prjnote == null) 
    prjnote = new tbl_ProjectNot(); 
    return View(prjnote); 
} 

[HttpPost] 
public ActionResult Note(tbl_ProjectNote prjnote) 
{ 
    if (prjnote.Name == null) 
    { 
     BilgiMesaji(Tur.Warn, "Note title can't null!"); 
     return RedirectToAction("Note", new { ProjectID = prjnote.ProjectID }); 
    } 
    if (!string.IsNullOrEmpty(prjnote.Name) && prjnote.Name.Length > 100) 
    { 
     BilgiMesaji(Tur.Warn, "Note title can not be more than 100 characters!"); 
     return RedirectToAction("Note", new { ProjectID = prjnote.ProjectID }); 
    } 
    if (!string.IsNullOrEmpty(prjnote.Content) && prjnote.Content.Length > 500) 
    { 
     BilgiMesaji(Tur.Warn, "Note content can not be more than 500 characters!"); 
     return RedirectToAction("Note", new { ProjectID = prjnote.ProjectID }); 
    } 

    var prjnoteDB = db.tbl_ProjectNote.FirstOrDefault(d => d.ID == prjnote.ID); 

    if (prjnoteDB == null) 
     prjnoteDB = new tbl_ProjectNot(); 

     prjnoteDB.Name = prjnote.Name; 
     prjnoteDB.Content = prjnote.Content; 
     prjnoteDB.ProjectID = prjnote.ProjectID; 
     if (prjnoteDB.ID == 0) 
     { 
      prjnoteDB.UserID = us.ID; 
      prjnoteDB.AddDate = DateTime.Now; 
      db.tbl_ProjectNot.Add(prjnoteDB); 
     } 
     db.SaveChanges(); 

     Sabitler.Note = db.tbl_ProjectNot.ToList(); 

     BilgiMesaji(Tur.Success, "Recording successfully added!"); 

     return RedirectToAction("Note", new { ProjectID = prjnote.ProjecID }); 
} 
+0

你能證明你返回「NoteListPartial」請查看控制器代碼。 –

+0

當然可以。我現在添加代碼。 – Shadouspan

+0

我加。你可以檢查嗎? – Shadouspan

回答

2

您需要返回用PartialView在public ActionResult Note(RaporModel Filter, int? ID)行動無法查看:

public ActionResult Note(RaporModel Filter, int? ID) 
{ 
    var prjnote = db.tbl_ProjectNot.FirstOrDefault(d => d.ID == ID); 
    if (prjnote == null) 
     prjnote = new tbl_ProjectNot(); 
    return PartialView(prjnote); 
} 

返回查看()將包含有你的頭和導航欄的_layout.cshtml頁面。

欲瞭解更多信息,請瀏覽: View() vs. PartialView()