2014-03-05 43 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