Aravind Ranganathan
asked on
not displaying the popup message
Hi there i have an c# web form application where i have a few text boxes and a gridview underneath the teaxtbox. but some of the textboxes are required field. so if the user forgets to enter those and directly tries to input data in the gridview i make a check to see if any of the required field above is empty if it is i pop a message box saying 'Please Make Sure The above Required fields are filled' the problem is it runs through the code with out popping the message and continues on to the try catch condition
here is the code
here is the code
protected void PiceCode(object sender, EventArgs e)
{
Checkifabovefieldsarenotempty(); <---- [b]this is the method that checks for empty controls, the problem is it runs through the code with out popping the message and continues on to the try catch condition[/b]
try
{
SqlConnection sqlcon = new SqlConnection(con);
string query = "Select Description FROM [Item Master] Where Item = \'" + ((TextBox)GridView1.HeaderRow.FindControl("TextBox3")).Text + "\'";
SqlCommand com = new SqlCommand(query, sqlcon);
sqlcon.Open();
var value = (com.ExecuteScalar());
((TextBox)GridView1.HeaderRow.FindControl("TextBox4")).Text = value.ToString().Trim();
sqlcon.Close();
if (value.ToString().Length > 0)
{
}
else
{
string script = "alert(\"the product code entered was not found\");";
ScriptManager.RegisterStartupScript(this, GetType(),
"ServerControlScript", script, true);
}
}
catch (Exception ex)
{
string script = "alert(" + ex.Message.ToString() + ");";
ScriptManager.RegisterStartupScript(this, GetType(),
"ServerControlScript", script, true);
}
}
public void Checkifabovefieldsarenotempty()
{
if (LineValues.SelectedIndex == 0 || todaydate.Text == string.Empty || shiftvalues.SelectedIndex == 0 || staffused.Text == string.Empty)
{
string script = "alert(\"Please Make Sure The above Required fields are filled\");";
ScriptManager.RegisterStartupScript(this, GetType(),
"ServerControlScript", script, true);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER