验证这些文本框只有最后一个工作 [英] Validating these textboxes only the last one works
问题描述
大家好,
我的朋友试图向我解释我的错误信息是如何被覆盖的,我尝试制作一个自定义变量来保存信息但我仍然得到同样的错误。
只有我的最后一次验证适用于这些文本框和我之前的所有文本框空白。
有人可以解释或帮我提出一个很好的解决方案吗?
这是我一直在做的工作。
也是开头的消息
-missing信息没有添加到我的任何错误中,虽然我做了+ =所以我认为它会被添加。< br $> b $ b
hello all,
my friend tried explaining to me how my error message is being overwritten and i tried making a custom variable to hold the message but i am still getting the same error.
Only my last validation works on these textboxes and all my ones before it are blank.
Could someone explain or help me come up with a good solution for these?
here is what i have been working on.
Also the beginning message
-missing information has not been added to any of my errors although i did a += so i thought that it would be added.
bool accountFlag = false;
string message = ""; //i just added this variable ...
lblAcctMsg.Text = "Missing Information";
if (this.txtAccountName.Text == "")
{
message = " - AccountName";
lblAcctMsg.Text += message; //" - AccountName";
lblAccountnameErr.Visible = true;
accountFlag = true;
}
else
{
message = "";
lblAccountnameErr.Visible = false;
lblAcctMsg.Text = "" + message;
}
//primary account id textbox
if (this.txtPrimaryAct.Text == "")
{
lblAcctMsg.Text += " - Primary AccountName";
lblPrimaryAccountIDError.Visible = true;
accountFlag = true;
}
else
{
lblPrimaryAccountIDError.Visible = false;
lblAcctMsg.Text = "";
}
try
{
double d = Convert.ToDouble(txtVolatility.Text);
if (this.txtVolatility.Text == "")
{
lblAcctMsg.Text = " - Volatility";
lblVolatilityError.Visible = true;
accountFlag = true;
}
else
{
lblVolatilityError.Visible = false;
lblAcctMsg.Text = "";
}
}
catch
{
lblAcctMsg.Text = " - Volatility";
lblVolatilityError.Visible = true;
accountFlag = true;
}
if (accountFlag)
return;
推荐答案
您是否在回帖后验证?
如果是这样,那么您可以使用隐藏字段为您存储邮件并相应地分配它们。
Are you validating on post back?
if so then you can use hidden fields to store the message for you and assign them accordingly.
这篇关于验证这些文本框只有最后一个工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!