如何让Label消失? [英] How to make Label disappear?

查看:141
本文介绍了如何让Label消失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,我想根据某些条件使Label消失。例如,如果var结果为空,那么我将Label的可见性设置为false,隐藏。

以下是我的代码,



Hi, I have the following codes, I want to make the Label disappear as according to some condition. For example, if the var result is empty, then I will set the Label's visibility to false, hidden.
Below are my codes,

var result = txtBatch.Text;
if(result.Equals(""))
{
    txtBatch.Visible = false;
    lblBatch.Visible = false;
}
else
{
    txtBatch.Visible = true;
    lblBatch.VIsible = true;
}





但在我尝试验证代码后,它会提示我txtBatch未定义错误。

以上代码不是用C#编写的,所以我不太清楚错误是什么,代码是用Loftware Label Design软件用脚本编写的。任何帮助,将不胜感激。紧急。谢谢。



But after I try to verify the codes, it prompt me txtBatch not defined error.
The above codes is not written in C# so I dont quite know what the error is, the codes is written in script using Loftware Label Design software. Any help would be appreciated. Urgent. Thank you.

推荐答案





假设你有一个类似如下的TextBox:

Hi,

Lets say you have a TextBox like the following:
<asp:textbox id="txtBatch" runat="Server" text="1234"></asp:textbox>



在javascript中执行以下操作以获取价值:


In javascript do the following to get value:

var result = document.getElementById('<%=txtBatch.ClientID%>').value;



由于TextBox是服务器控件,所以在运行时这个控件有不同客户ID


As TextBox is server control, so on runtime this control have different client id

'<%=txtBatch.ClientID%>'

将在运行时返回控件clientid

然后你可以写

will return control clientid on runtime
Then you can write

if(result.Equals(""))





希望这会有所帮助!! :)



问候,

Praneet



Hope this helps !! :)

Regards,
Praneet


从我的研究中,我出来了建议。以下是我的代码/脚本:



From my research, I have come out with a suggestion. Below are my codes/scripts:

if(label.fields.field.(@name == 'SerNumber2').@data.IsNullOrEmpty){
label.fields.field.(@name == 'SerNumber2').@printingField = "false"
}

else
{
label.fields.field.(@name == 'SerNumber2').@printingField = "true"
}





由于我在Loftware Label Design软件中编写代码,因此语法如上所示。 @name和@printingfield不是提示用户输入某些值的参数,但它们分别表现为数据类型和可见性。希望能帮助到你。谢谢。



Due to I am writing the codes in Loftware Label Design software, the syntax would be looked as the above. @name and @printingfield are not params that will prompt users to enter some value but they act like data type and visibility respectively. Hope it helps. Thank you.


这篇关于如何让Label消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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