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.
The trigger is defined by using the <asp:AsyncPostBackTrigger> element inside the<Triggers> element of the
UpdatePanel control. (If you are editing the page in Visual Studio, you can create triggers by using theUpdatePanelTrigger Collection Editor dialog box.)
codeplus123
0 Points
9 Posts
AsyncPostBackTrigger not firing
Nov 26, 2012 09:00 PM|LINK
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;
}
}
codeplus123
0 Points
9 Posts
Re: AsyncPostBackTrigger not firing
Nov 26, 2012 09:02 PM|LINK
</ContentTemplate> has an opening tag by the way i didnt add all of the code.
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: AsyncPostBackTrigger not firing
Nov 27, 2012 02:46 AM|LINK
The trigger is defined by using the <asp:AsyncPostBackTrigger> element inside the<Triggers> element of the UpdatePanel control. (If you are editing the page in Visual Studio, you can create triggers by using theUpdatePanelTrigger Collection Editor dialog box.)
http://msdn.microsoft.com/en-us/library/system.web.ui.asyncpostbacktrigger.aspx
http://forums.asp.net/t/1801357.aspx/2/10
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
codeplus123
0 Points
9 Posts
Re: AsyncPostBackTrigger not firing
Nov 27, 2012 08:47 AM|LINK
I have done it if you read the first part of my code...