标签的可见属性有问题 [英] Problem with visible property of a label

查看:57
本文介绍了标签的可见属性有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我已经贴了一个标签,用于向用户显示消息.
我有一个下拉列表.如果下拉列表的项目计数为0,我想向用户显示标签,否则不显示.我做了以下工作,但是没有按预期工作.您能告诉我这段代码有什么问题吗?我应该怎么做才能获得预期的结果?

Hello all!!

I have taken a label for showing message to the user.
I have a dropdown-list. If the Item Count of dropdown list is 0, i want to show the label to the user else not. I did the following but it''s not working as expected. Can you please tell me what''s wrong with this code and what should i do to get the expected result ??

<asp:Label ID="lblMessage" runat="server" Text="Currently there are no products in this category" Visible='<%# bool.Parse((ddlProducts.Items.Count==0).ToString())%>' Font-Bold="true" Font-Italic="true" Font-Names="Georgea"></asp:Label>
</td>



它总是将标签设置为可见,而当项目计数不为零时,则不应向用户显示.



It''s always setting the label as visible whereas when the item count is not zero it should not be shown to the User.

推荐答案

我认为如果u在您需要的页面加载时进行检查,
if(ddlProducts.Item.Count == 0)
{
lblMessage.visible = true;
}
并使用aspx语法visible ="false"保留其visible属性.我认为这可以解决您的问题.
i think its better if u check it on page load where u required it as,
if(ddlProducts.Item.Count == 0)
{
lblMessage.visible = true;
}
and keep its visible property in aspx syntax visible="false". i think this may solve your problem.


这篇关于标签的可见属性有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆