[英]MVC4 Html formatted string in JSON result
Hi all I have written a sample code to check an user available with the given name, if available I would like to display the text with Red
color saying Username in use, for this I have written as follows but the text is not showing 大家好,我编写了一个示例代码来检查具有给定名称的可用用户,如果可用,我想显示
Red
的文本,表示正在使用用户名,为此,我编写了以下内容,但该文本未显示
[OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
public JsonResult IsUserNameAvailable(string UserName)
{
var usrAvailable = db.tblUsers.Where(p => p.UserName == UserName).Select(img => img.UserName).FirstOrDefault();
if (usrAvailable == null)
{
return Json("Username is available", JsonRequestBehavior.AllowGet);
}
return Json("<span style='color:Red;> Username in use</span>", JsonRequestBehavior.AllowGet);
}
Can some one help me 有人能帮我吗
"<span style='color:Red;> Username in use</span>"
style
quote not closed style
报价未关闭
AND 和
return Json()
could be raplaced with return Content()
return Json()
可以与return Content()
放在一起
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.