Posts

How To Use AJAX Control Toolkit

1. Download the Toolkit at http://ajaxcontroltoolkit.codeplex.com/ 3. Extract the download 4. Add reference to AjaxControlToolKit.DLL 5. Register the DLL on your aspx page <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <!DOCTYPE html> 6. Add ToolkitScriptManager <form id="form1" runat="server"> <div> <asp:ToolkitScriptManager ID="ToolKitManager1" runat="server"></asp:ToolkitScriptManager>

ASP.NET: Call Stored Procedure Using SqlCommand and SqlDataReader

A lot of times you want to call a stored procedure quickly in the code to access the stored procedure.  You don't want to go through the trouble of dragging an SqlDataSource control in the design view just to use the stored procedure. Here is how you would call the "Top Ten Most Expensive Products" stored procedure in the Northwind database. 1.  First you need the namespaces using System.Web.Configuration; using System.Data.SqlClient; using System.Data; 2. Then get the Northwind connection string value from the Web.config file string connectString = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"]. ConnectionString; 3. Now call the stored procedure and output the result from the SqlDataReader using (SqlConnection conn = new SqlConnection(connectString)) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "GetProductsAvgPrice"; cmd.CommandType = CommandType.Stor...