I have two dropdown , the items in the second drop down solely depends on the selected item from the first dropdown. So therefore i want the second dropdows item changes on item selection from the first dropdown. My first drop down is as follows
<td>
<asp:DropDownList ID="DropClient" runat="server" style="margin-left: 0px" AutoPostBack="true" Width="200px" OnTextChanged="DropClient_TextChanged">
</asp:DropDownList> </td>
<td>
I wanted to use onselectedindexchanged previously , but it does not fires as required. Therefore i put my method in the onTextChanged events as below.
protected void DropClient_TextChanged(object sender, EventArgs e)
{
bindDrEmail();
}
and my bindEmail();
connection.Open();
string sql = "SELECT a.clientID,a.cname,c.name FROM [CLIENT] a INNER JOIN [BRANCH] b ON a.clientID=b.clientID JOIN [CONTACT] c ON b.bid=c.bid WHERE a.cname =#clientname";
SqlCommand cmd = new SqlCommand(sql, connection);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("#clientname", DropClient.SelectedItem.Text);
SqlDataReader reader = cmd.ExecuteReader();
drEmail.Enabled = true;
drEmail.DataSource = reader;
drEmail.DataTextField = "name";
drEmail.DataValueField = "clientID";
drEmail.DataBind();
reader.Dispose();
reader.Close();
connection.Close();
the above works as expected, but after i select an item in the second dropdown, it does not submit the selected item as chosen . It rather submit the first item in the list by default. Also when i click the submit button, it quickly refresh and submit the first item in the list. I am confused, any help would be appreciated.
Why don't you use onSeletedIndexChanged event, call same function on onSeletedIndexChanged event, may be it will be helpful for you
OnSelectedIndexChanged="cboRegion_SelectedIndexChanged"
Place the code to bind the first dropdown inside the !IsPostBack check
if (!Page.IsPostBack)
{
//Bind your first dropdown here
}
The page load gets triggered everytime a postback happens so to prevent your code loading everytime and resetting your dropdownlists do the following:
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//Put your code in here. This will only load the first time the page loads.
bindDrEmail();
}
}
You can use Update Panel .
This is example code ,
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
<asp:ListItem Value="0">Choose...</asp:ListItem>
<asp:ListItem Value="1">test1</asp:ListItem>
<asp:ListItem Value="2">Test2</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
Guys thank all for your time. I finally figured out the problem. First the reson why it does not fires the events previously was because i set the second Dropdown "AutoPostback" as true, and didn't set the same for the first DropDown which i want to fires. When i reverse this process it fires as below.
<asp:DropDownList ID="DropDownClient" runat="server" style="margin-left: 0px" AutoPostBack="true"
Width="200px" onselectedindexchanged="DropDownClient_SelectedIndexChanged">
</asp:DropDownList>
And
<asp:DropDownList ID="drContact" runat="server" style="margin-left: 0px" Width="200px"> </asp:DropDownList>
Now it fires. Second the very reason why the selecteditem from the second Dropdown changes quickly on button click and submit the first item instead, was because of the dataValueField of the second DropDown. My convine the two tables as follows.
string sql = "SELECT a.clientID,a.cname,c.contactID,c.name FROM [CLIENT] a INNER JOIN [BRANCH] b ON a.clientID=b.clientID JOIN [CONTACT] c ON b.bid=c.bid WHERE a.cname =#clientname";
SqlCommand cmd = new SqlCommand(sql, connection);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("#clientname", DropDownClient.SelectedItem.Text);
SqlDataReader reader = cmd.ExecuteReader();
drContact.Enabled = true;
drContact.DataSource = reader;
drContact.DataTextField = "name";
drContact.DataValueField = "clientID";
drContact.DataBind();
Notice the drContact.DataValueField is set as "clientID" . And clientID and the drContact.DataTextField are from different tables. The column i required is "name" and therefore have to change the drContact.DataValueField to the primary key of the table where name is a column. And therefore.
drContact.Enabled = true;
drContact.DataSource = reader;
drContact.DataTextField = "name";
drContact.DataValueField = "contactID";
drContact.DataBind();
The above works fine for me. Thanks for your time.
Related
I have a gridview showing academy name and a dropdown list. The dropdown list have value of 0-13, 0 is the "Please select option". I want when the save button it skip those row where there is no selection in the dropdown therefore 0.
Here is my code for the gridview:
<asp:GridView ID="gdvAcadSelec" runat="server" AutoGenerateColumns="False"
DataKeyNames="acad_Id"
DataSourceID="srcAcademy"
OnRowDataBound="gdvAcadSelec_RowDataBound"
CssClass="table table-striped table-bordered"
EnableViewState="False">
<Columns>
<asp:BoundField DataField="acad_Id" HeaderText="Id" />
<asp:BoundField DataField="acad_name" HeaderText="Academy" />
<asp:TemplateField HeaderText="Choice">
<ItemTemplate>
<asp:DropDownList ID="ddlPref" OnTextChanged="ddlPref_TextChanged" AutoPostBack="true" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btnsubmit" CssClass="btn btn-info" OnClick="btnsubmit_Click" runat="server" Text="Submit" />
<asp:ObjectDataSource ID="srcAcademy"
TypeName="dataAccessLayer"
SelectMethod="getAcademy"
runat="server" />
The code behind for the binding of item for the column Choice:
protected void gdvAcadSelec_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Find the DropDownList in the Row
DropDownList ddlCountries = (e.Row.FindControl("ddlPref") as DropDownList);
ddlCountries.Items.Insert(0, new ListItem("Please select"));
ddlCountries.Items.Insert(1, new ListItem("1"));
ddlCountries.Items.Insert(2, new ListItem("2"));
ddlCountries.Items.Insert(3, new ListItem("3"));
ddlCountries.Items.Insert(4, new ListItem("4"));
ddlCountries.Items.Insert(5, new ListItem("5"));
ddlCountries.Items.Insert(6, new ListItem("6"));
ddlCountries.Items.Insert(7, new ListItem("7"));
ddlCountries.Items.Insert(8, new ListItem("8"));
ddlCountries.Items.Insert(9, new ListItem("9"));
ddlCountries.Items.Insert(10, new ListItem("10"));
ddlCountries.Items.Insert(11, new ListItem("11"));
ddlCountries.Items.Insert(12, new ListItem("12"));
ddlCountries.Items.Insert(13, new ListItem("13"));
}
On click save button:
protected void btnsubmit_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in gdvAcadSelec.Rows)
{
DropDownList ddlorder = (DropDownList)row.FindControl("ddlPref");
string acadID = row.Cells[0].Text;
string order = ddlorder.SelectedValue.ToString();
SqlCommand scmd = new SqlCommand();
scmd.CommandType = CommandType.Text;
scmd.CommandText = "Insert into tblAcademy_Selection (acad_Id,stud_Id,order_preference) values (#acad,#stud,#order)";
scmd.Connection = con;
scmd.Parameters.AddWithValue("#acad", acadID);
scmd.Parameters.AddWithValue("#stud", 60);
scmd.Parameters.AddWithValue("#order", order);
con.Open();
scmd.ExecuteNonQuery();
con.Close();
}
}
The problem with this code is when it is saving to the database ,those dropdowns list who have value "please select" is also being save and this crash my website.
What can I do to skip those dropdown that do not have value selected?
Thank you in advance.
(Edited per request from OP)
Simply use an if() statement to skip the values you don't want to insert.
string order = ddlorder.SelectedIndex.ToString();
if (order != "0") { // Some may argue that it should be !order.equals("0") but in C# it doesn't matter.
SqlCommand scmd = new SqlCommand();
scmd.CommandType = CommandType.Text;
.
.
}
And if you're a prudent (and paranoid) programmer, you won't trust anything sent from the browser, you'll check to make sure the variable order is the appropriate type and is within the range of values you expect as well.
I am programming in ASP.NET, visual studio. I have a dropdown list created in HTML form. If I dropdown the list, it displays the record from associated column in the table. But what I want is to show the corresponding value / record with that list item.
For example in the table, I have column id, productname and price. After choosing a particular product name (from drop down list), the associated price with it must be displayed in front of it (in a label).
However, By default, I want the drop down list to shows nothing in the beginning.
UPDATE:
Store.aspx:
<form id="form1" runat="server">
<div>
Welcome
<asp:Label ID="Label3" runat="server" ></asp:Label>
<br />
<br />
Products: <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" ></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [productdata]"></asp:SqlDataSource>
Price:
<asp:Label ID="Label1" runat="server" ></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Add to Cart" />
<br />
<br />
Items in cart: <asp:DropDownList ID="DropDownList2" runat="server"></asp:DropDownList>
<br />
<br />
Total Price: <asp:Label ID="Label2" runat="server"></asp:Label>
</div>
</form>
Store.aspx.cs:
public partial class Store : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label3.Text = Request.QueryString["name"];//show welcome text
String cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
if (!IsPostBack)
{
using (SqlConnection sc = new SqlConnection(cs))
{
SqlCommand sqlcom = new SqlCommand("Select id, productname, price from productdata", sc);
sc.Open();
DropDownList1.DataTextField = "productname";//show in the dropdown list
DropDownList1.DataValueField = "price"; //show in the label
DropDownList1.DataSource = sqlcom.ExecuteReader();
DropDownList1.DataBind();
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
String cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlDataReader rd;
using (SqlConnection sc = new SqlConnection(cs))
{
SqlCommand sqlcom = new SqlCommand("Select id, productname, price from productdata where id=" + Convert.ToUInt32(DropDownList1.SelectedValue), sc);
sc.Open();
rd = sqlcom.ExecuteReader();
if (rd.Read())
{
Label1.Text = rd[2].ToString();
}
sc.Close();
}
}
}
Database:
CREATE TABLE [dbo].[productdata] (
[Id] INT NOT NULL,
[productname] VARCHAR (50) NULL,
[price] FLOAT (53) NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
This Edit according to using AutoPostBack=True and if (!IsPostBack) in Page_Load thanks to Arindam:
For simply solution using postback event:
First you should add OnSelectedIndexChanged event for dropdownlist
<asp:DropDownList ID="DropDownList1" runat="server"
OnSelectedIndexChanged="GetPrice" AutoPostBack="true">
</asp:DropDownList>
Then in code behind you just get selected value and fill to the label price
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Label3.Text = Request.QueryString["name"];//show welcome text
String cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection sc = new SqlConnection(cs))
{
SqlCommand sqlcom = new SqlCommand("Select id, productname, price from productdata", sc);
sc.Open();
DropDownList1.DataTextField = "productname";//show in the dropdown list
DropDownList1.DataValueField = "price"; //show in the label
DropDownList1.DataSource = sqlcom.ExecuteReader();
DropDownList1.DataBind();
}
}
}
protected void GetPrice(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedValue;
}
You have to use AutoPostBack=True so that when you change index of dropdownlist, it will trigger a postback to server so the function GetPrice(...) will be called.
Every time the page postback, it will call function Page_Load(...) first, so you must use propertive IsPostBack to check if case1_this is the first time the page is loaded, or case2_a postback event, and you only set the ddl datasource at case1 because if you set datasource, by default the dropdownlist will reset to select first item in list.
When you go advance, you should consider using Javascript and Jquery to solve this, so the page will not load again like this postback solution.
And one more thing, you should name your controls well, don't make them default like that. It's one of two hard things in programming.
Yes you can but if not please use datatable and i am sure that work fine .if u not able do that just post I will give the correction.
i am new on .net development now i am facing the problem but i do not know what the solution for this
i am creating the dropdown list and bind it with data but when i select the any data from list it does not changes the textbox with the related value but when i click on button it goes inside the code means goes on debuging from where i mark the debug cursor
here is my code behind
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string selectedCardCode = DropDownList1.SelectedItem.Value;
SqlConnection connection = new SqlConnection("Data Source=testing;Initial Catalog=testdb;Persist Security Info=True;User ID=abcd;Password=asdfg");
using (connection)
{
SqlCommand theCommand = new SqlCommand("SELECT T1.CardCode , T1.CardName,T3.CntctCode,T3.Name FROM OCRD T1 inner join OCPR T3 on T1.CardCode=T3.CardCode where T3.CardCode=#CardCode ", connection);
connection.Open();
theCommand.Parameters.AddWithValue("#CardCode", selectedCardCode);
theCommand.CommandType = CommandType.Text;
SqlDataReader theReader = theCommand.ExecuteReader();
if (theReader.Read())
{
this.TextBox1.Text = theReader["CardCode"].ToString();
this.TextBox2.Text = theReader["CardName"].ToString();
this.DropDownList1.SelectedItem.Value = selectedCardCode;
}
connection.Close();
}
}
and here is my method cardcode
protected void LoadOptionsCardCodeTable()
{
DataTable CardCode = new DataTable();
string id, name, newName;
SqlConnection connection = new SqlConnection("Data Source=abc;Initial Catalog=TestDataBase;Persist Security Info=True;User ID=asdf;Password=asdfgh");
using (connection)
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT T1.CardCode , T1.CardName from ocrd T1 ", connection);
adapter.Fill(CardCode);
if (CardCode.Rows.Count > 0)
{
for (int i = 0; i < CardCode.Rows.Count; i++)
{
id = CardCode.Rows[i]["CardCode"].ToString();
name = CardCode.Rows[i]["CardName"].ToString();
newName = name + " ---- " + id;
DropDownList1.Items.Add(new ListItem(newName, id));
}
}
}
}
here is my design code
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server"
ondatabinding="DropDownList1_SelectedIndexChanged"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" ontextchanged="TextBox2_TextChanged"></asp:TextBox>
</form>
Kindly help your help will be higly appreciatable
Set AutoPostBack property to true for your dropdownlist.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
ondatabinding="DropDownList1_SelectedIndexChanged"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
By default, asp.net server controls like dropdownlist, textbox have their respective events as cached which means it registers the event but does not fire untill an actual postback happens. In you case when you are clicking the button a postback is happening and the cached event of your dropdwonlist is also getting executed.
To force postback from your dropdown you will have to set the PostBack property to true.
You have to set AutoPostBack="true" in order to trigger the event:
<asp:DropDownList ID="DropDownList1" runat="server"
ondatabinding="DropDownList1_SelectedIndexChanged"
onselectedindexchanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
Notes:
A postback is initiated by the browser, and reloads the whole page, according to an event.if any changes(here onselectedindexchanged) we made in the control result in a postback then that are called AutoPostBack.All controls except, Buttons, Hyperlinks and LinkButtons have a default AutoPostBack property of false, we have an option to make them true if needed.
Set AutoPostBack="true" Otherwise DropDownList1_SelectedIndexChanged doesn't fire.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
ondatabinding="DropDownList1_SelectedIndexChanged"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
I want to bind a Hidden Field because I want to pass a value from code behind to the asp:Parameter Name="HOME_TEAM_COACH_ID" Type="Int32".
My asp:
<asp:FormView ID="FormView1" runat="server" OnItemUpdated="FormView1_ItemUpdating" >
<EditItemTemplate>
HOME_TEAM:
<asp:DropDownList ID="DropDownListHometeam" runat="server"
DataSourceID="SqlDataGetTeams"
DataTextField="NAME" DataValueField="ID" SelectedValue='<%# Bind("HOME_TEAM_ID") %>'>
</asp:DropDownList>
<asp:HiddenField runat="server" ID="testLabel" Value='<%# Bind("HOME_TEAM_COACH_ID") %>' />
</EditItemTemplate>
And c# behind is:
protected void FormView1_ItemUpdating(object sender, FormViewUpdatedEventArgs e)
{
if (FormView1.CurrentMode == FormViewMode.Edit)
{
DropDownList HomeTeamId = FormView1.FindControl("DropDownListHometeam") as DropDownList;
string team = string.Format("{0}", HomeTeamId.Text);
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BasketballConnectionString1"].ToString());
conn.Open();
string queryHome = "SELECT dbo.COACH.ID, dbo.COACH.SURENAME FROM dbo.COACH INNER JOIN dbo.GAMES ON dbo.COACH.TEAM_ID = dbo.GAMES.HOME_TEAM_ID WHERE (dbo.GAMES.HOME_TEAM_ID =" + team + ")";
SqlCommand cmd = new SqlCommand(queryHome, conn);
var Home_Coach_Id = cmd.ExecuteScalar().ToString();
HiddenField HomeCoachIdLabel = FormView1.FindControl("testLabel") as HiddenField;
HomeCoachIdLabel.Value = Convert.ToString(Home_Coach_Id);
conn.Close();
I want Help with the last four lines where I want to pass the Home_Coach_Id value to bind the asp:HiddenField ID="testLabel" Value='<%# Bind("HOME_TEAM_COACH_ID") %>'.
When I click update, it doesn't change the value in database. (When I debug, in the last lines it gives me the correct HomeCoachIdLabel.Value.)
any suggestions?
You do not need the explicitly set the HiddenField's Value property, because it is done by the <%# Bind("HOME_TEAM_COACH_ID") %> in your markup.
I believe your problem is that you are not returning the HOME_TEAM_COACH_ID from your query to the database in your SELECT statement:
SELECT dbo.COACH.ID, dbo.COACH.SURENAME FROM dbo.COACH
INNER JOIN dbo.GAMES ON dbo.COACH.TEAM_ID = dbo.GAMES.HOME_TEAM_ID
WHERE (dbo.GAMES.HOME_TEAM_ID =" + team + ")
The problem is that it needs the method prerender and not the method onitemupdated.
asp:FormView ID="FormView1" runat="server" OnPreRender="FormView1_OnPreRender" >
and also in c#
protected void FormView1_OnPreRender(object sender, FormViewUpdatedEventArgs e)
{
It also works when I put it in page load{ }.
The next step is to make the insert event....
I am making a project in ASP.NET WebForms. Although I have done it so many times but dropdown list is troubling me a lot this time.
I fetch items from DB and then add them to my dropdown list one by one using FOR loop. That works fine. But the problem is that I cannot select an item from list comfortably, whenever I try to select an item from the drop down list, it snaps the selection to the first element, it becomes very difficult to select the desired item.
How could I fix that?
Suppose I move my cursor over the 9th item in the list then also it selects the 1st and 9th item alternatively so fast that I see both of them as selected.
CodeBehind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DropDownList1.Items.Clear();
con.ConnectionString = ConfigurationManager.ConnectionStrings["familyConnectionString"].ConnectionString;
con.Open();
adp = new SqlDataAdapter("select distinct family_head from family", con);
DataSet ds = new DataSet();
adp.Fill(ds, "family");
con.Close();
for (int i = 0; i < ds.Tables["family"].Rows.Count; i++)
DropDownList1.Items.Add(ds.Tables["family"].Rows[i][0].ToString());
}
}
ASPX
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:DropDownList ID="DropDownList1" runat="server" Width="150px">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" Width="150px">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Height="30px" onclick="Button1_Click"
Text="Submit" Width="145px" BackColor="#465767" ForeColor="White" />
<asp:RoundedCornersExtender ID="Button1_RoundedCornersExtender" runat="server"
Enabled="True" TargetControlID="Button1" Corners="All" Radius="10">
</asp:RoundedCornersExtender>
<br />
<br />
<br />
</asp:Content>
A CSS Keyframes Animation is working in page background, Can that be a cause?
There seems to be some kind of confusion, as to how databinding works for WebControls. The best reference for that is: http://msdn.microsoft.com/en-us/library/ms178472.aspx
Under the assumption, that all the binding code for DropDownList1 is shown:
DropDownList1.Items.Clear();
shouldn't be neccesary, as the items shouldn't persist per PostBack. (At least I assume that, because all Items will be lost after each PostBack if the DataSource isn't bound again).
The DropDownList needs have the items on each PostBack, if you want to use the DropDownList. You are using
if (!Page.IsPostBack)
which means, that you don't bind the items again, if you have a PostBack. In the link posted above, you can see that Controls set their properties (like which item was selected before clicking a Button) during the LoadEvent, which means that the items need to be binded earlier in the lifecycle, like during OnInit.
Try something like this:
protected void BindDropDownList1()
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["familyConnectionString"].ConnectionString;
con.Open();
adp = new SqlDataAdapter("select distinct family_head from family", con);
DataSet ds = new DataSet();
adp.Fill(ds, "family");
con.Close();
for (int i = 0; i < ds.Tables["family"].Rows.Count; i++)
DropDownList1.Items.Add(ds.Tables["family"].Rows[i][0].ToString());
}
protected override void OnInit(EventArgs e)
{
this.BindDropDownList1();
base.OnInit(e);
}
Another suggestion would be to you the DataSource property of the DropDownList, instead of DropDownList1.Items.Add. If you use this approach, you need to set the DataKeyValue and DataKeyMember properties of the DropDownList:
protected void BindDropDownList1()
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["familyConnectionString"].ConnectionString;
con.Open();
adp = new SqlDataAdapter("select distinct family_head from family", con);
DataSet ds = new DataSet();
adp.Fill(ds, "family");
con.Close();
DropDownList1.DataSource = ds;
DropDownList1.DataBind();
}
Edit:
I think I found your error. You are using controls from the AjaxControlToolKit, but are still using the ScriptManager. For about 2 years, controls from the AjaxControlToolKit require the ToolkitScriptManager. Replace the ScriptManager with a ToolkitScriptManager.