2014-03-05 39 views
0

如何設置標籤的值與文本框的字符串值返回的字符串分配給一個標籤在MVC

public ActionResult getComment(string comBox) 
{ 
    var commentBox = comBox; 
    Convert.ToString("commentBox"); 
    Console.Write("commentBox"); 
    return PartialView("getComment"); 
} 

而且在我的局部視圖一個想要顯示的標籤上這個字符串。

如何做到這一點?

基本上是一個評論框,我想實現。

回答

0

如果我理解你的問題,你要顯示的評論在您的局部視圖的標籤

管窺getComment.cshtml

<label>@ViewBag.Comment</label> 

行動

public ActionResult getComment(string comBox) 
{ 
    var commentBox = comBox; 
    ViewBag.Comment=commentBox;// or whatever string you want 
    return PartialViewResult(); 
} 
+0

先生,你能提供更多的細節。它不工作。標籤字段沒有設置。 – user43553

+0

@ user43553,請添加您的部分視圖代碼。很難說沒有你的觀點 –

+0

此我的行動領域: 公衆的ActionResult getComment(字符串MyComment) {VAR = commentBox MyComment; ViewBag.Comment = commentBox; return PartialView(「getComment」); } – user43553