从JQuery检查ViewBag中是否存在值

时间:2012-12-26 10:11:31

标签: c# jquery asp.net viewbag

我尝试检查JQuery中是否存在 ViewBag 中的值:

if("<%: ViewBag.isSearchEnabled %>" != null && "<%: ViewBag.isSearchEnabled %>" != "True")
        {
        $("#CompanySearchPanel").hide();
        }  

这应该根据this工作,但它会出现以下错误:

The call is ambiguous between the following methods or properties: 'System.IO.TextWriter.Write(string, params object[])' and 'System.IO.TextWriter.Write(char[])'  

仅供参考, ViewBag 中不存在此值。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

我刚刚找到了this链接,其中提到了类型转换是解决方案。不知道需要铸造类型。我刚刚做了这个,它正在发挥作用。

如果这是正确的原因,请提出建议。

相关问题