我有一個YES/NO問題列表,每個問題都有一個單選按鈕,指示答案。當用戶選擇YES時,panel
將可見,並且其中具有用於額外所需輸入的文本框。當用戶回答YES時,他們必須填寫出現的文本框。檢查有條件隱藏的文本框是否有值
目前我硬編碼這樣說:
if (txtQ1Specify.Visible == true)
{
if (txtQ1Specify.Text.Length == 0)
{
lblError.Text = "Please answer all questions.";
}
}
if (txtQ2Specify.Visible == true)
{
if (txtQ2Specify.Text.Length == 0)
{
lblError.Text = "Please answer all questions.";
}
}
if (txtQ3Specify.Visible == true)
{
if (txtQ3Specify.Text.Length == 0)
{
lblError.Text = "Please answer all questions.";
}
}
if (txtQ4SpecifyCompany.Visible == true || txtQ4SpecifyRelative.Visible == true)
{
if (txtQ4SpecifyCompany.Text.Length == 0 || txtQ4SpecifyRelative.Text.Length == 0)
{
lblError.Text = "Please answer all questions.";
}
}
if (txtQ5SpecifyCompany.Visible == true || txtQ5SpecifyRelative.Visible == true)
{
if (txtQ5SpecifyCompany.Text.Length == 0 || txtQ5SpecifyRelative.Text.Length == 0)
{
lblError.Text = "Please answer all questions.";
}
}
if (txtQ6Specify.Visible == true)
{
if (txtQ6Specify.Text.Length == 0)
{
lblError.Text = "Please answer all questions.";
}
}
if (txtQ7Specify.Visible == true)
{
if (txtQ7Specify.Text.Length == 0)
{
lblError.Text = "Please answer all questions.";
}
}
這個檢查我想執行一些代碼後。
的頁面看起來是這樣的:
我如何檢查基於文本框的可見性投入?
不清楚你在問什麼。 – Mairaj