Basically, I have a div "Regerror" that will show when the button "sb" is clicked. The Regerror div isnt showing when the button sb is clicked but its posting data to database as normal. cant seem to find out why its not showing the div Regerror when button is clicked and input field "em" is empty.
<div id="regError" runat="server">
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="sb" EventName="serverclick" />
</Triggers>
</asp:UpdatePanel>
<p> </p>
<p>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<input type="text" id="em" name="em" runat="server"/>
</p> </ContentTemplate></asp:UpdatePanel>
<p><div id="split">
<input type="text" id="ln" name="ln" runat ="server" />
</p></div>
server side:
protected void Page_Load(object sender, EventArgs e)
{
UpdatePanel4.Visible =false;
con.Open();
}
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void sb_Click(object sender, EventArgs e)
{
DateTime age = new DateTime(Convert.ToInt32(year.Value), Convert.ToInt32(date.Value), Convert.ToInt32(day.Value));
SqlCommand cmd = new SqlCommand("insert into Register values ( '" + em.Value + "','" + ln.Value + "','" + select.Value + "','" + fn.Value + "','" + pwr.Value + "','" + age + "','" + pw.Value + "')", con);
cmd.ExecuteNonQuery();
con.Close();
if (em.Value == "") {
UpdatePanel4.Visible = true;
}
}