TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
26
3.9k
Why does my label under the textbox is visible?
Aug 24 2018 2:09 AM
private bool IsFilled()
{
if (TextBox1.Text == "" || TextBox3.Text == "" || TextBox4.Text == "" || TextBox5.Text == "" )
{
if (TextBox1.Text == "")
{
lblrn.Visible = true;
}
else
lblrn.Visible = false;
{
}
if (TextBox3.Text == "")
{
lbllocal.Visible = true;
}
else
lbllocal.Visible = false;
{
}
if (TextBox4.Text == "")
{
lblCN.Visible = true;
}
else
lblCN.Visible = false;
{
}
if (TextBox5.Text == "")
{
lblWS.Visible = true;
}
else
lblWS.Visible = false;
{
}
return true;
}
else
{
lblrn.Visible = false;
lbllocal.Visible = false;
lblCN.Visible = false;
lblWS.Visible = false;
return false;
}
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
if (IsFilled())
{
lblrn.Visible = false;
lbllocal.Visible = false;
lblCN.Visible = false;
lblWS.Visible = false;
}
else
{
Con.Open();
cmd = new SqlCommand("INSERT INTO Trans_Request ([Requestor_LName],[Local],[Computer_Name],[Work_Schedule],[Date_Created],[Work_Station],[Business_Group])VALUES (@Requestor_LName,@Local,@Computer_Name,@Work_Schedule,@Date_Created,@Work_Station,@Business_Group)", Con);
//string sqlFormattedDate = myDateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
cmd.Parameters.AddWithValue("@Requestor_LName", TextBox1.Text);
cmd.Parameters.AddWithValue("@Local", TextBox3.Text);
cmd.Parameters.AddWithValue("@Computer_Name", TextBox4.Text);
cmd.Parameters.AddWithValue("@Work_Schedule", TextBox5.Text);
cmd.Parameters.AddWithValue("@Date_Created", TextBox2.Text);
cmd.Parameters.AddWithValue("@Work_Station", TextBox6.Text);
cmd.Parameters.AddWithValue("@Business_Group", TextBox7.Text);
cmd.ExecuteNonQuery();
Con.Close();
ClearTextBox();
//end
}
}
even if my declaration is already on a false statement?
Reply
Answers (
2
)
Login using existing logic in MVC 5
Multiple conditions in If Else in C#