I am using ajax calender extender on my website.
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>Active From: <asp:TextBox ID="inputActiveFromDate" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="inputActiveFromDate" PopupButtonID="btn_Calendar1" Format="dd/MM/yyyy 00:00:00"></cc1:CalendarExtender>
<asp:ImageButton runat="server" ID="btn_Calendar1" ImageUrl="../images/buttons/Lock_icon.gif" />
</td>
<td width="20"></td>
<td>Active Until: <asp:TextBox ID="inputActiveUntilDate" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="inputActiveUntilDate" PopupButtonID="btn_Calendar2" Format="dd/MM/yyyy 23:59:59"></cc1:CalendarExtender>
<asp:ImageButton runat="server" ID="btn_Calendar2" ImageUrl="../images/buttons/Lock_icon.gif" />
</td>
</tr>
</table>
everything is working fine, but i am getting this error on all the browsers.
> Unable to set value of the property 'PopupBehavior': object is null or
> undefined
please help me to solve
Error comes at
// Name: MicrosoftAjax.debug.js
// Assembly: AjaxControlToolkit
// Version: 4.1.50508.0
// FileVersion: 4.1.50508
// (c) 2010 CodePlex Foundation
initialize: function Behavior$initialize() {
Sys.UI.Behavior.callBaseMethod(this, 'initialize');
var name = this.get_name();
if (name) this._element[name] = this;// error place <---
},
MY CS CODE:
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ToString())){
String sql = "INSERT INTO tablename (SDate,EDate) VALUES ('" + Convert.ToDateTime(inputActiveFromDate.Text) + "','" + Convert.ToDateTime(inputActiveUntilDate.Text) + "'); SELECT @@IDENTITY;";conn.Open();
SqlCommand comm = new SqlCommand(sql, conn);
comm.ExecuteNonQuery();
// int lastId = Convert.ToInt32(comm.ExecuteScalar());
conn.Close();
}
I believe the issue is because of you are using the PopupButtonID option and passing in the textbox id
You either need to remove this option or pass in an id of an actual button
<asp:TextBox ID="inputActiveUntilDate" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="inputActiveUntilDate" Format="dd/MM/yyyy 23:59:59"></cc1:CalendarExtender>
OR
<asp:TextBox ID="inputActiveUntilDate" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="inputActiveUntilDate" PopupButtonID="btn_Calendar" Format="dd/MM/yyyy 23:59:59"></cc1:CalendarExtender>
<asp:ImageButton runat="server" ID="btn_Calendar" ImageUrl="PathToACalendarButton" />
Edit:
I dont know much about sql injection risks, but it seems to me that it could be definitely be possible in your code. You may want to think about using parameterized queries such as stored procedures.