Skip to main content

Posts

Showing posts from March, 2008

GridView Alphabet Paging

Introduction: GridView paging feature allow us to display fixed number of records on the page and browse to the next page of records. Although paging is a great feature but sometimes we need to view all the items alphabetically. The idea behind this article is to provide a user with a list of all the alphabets and when the user clicks on a certain alphabet then all the records starting with that alphabet will be populated in the GridView control. Populating the GridView Control: The first task is to populate the GridView control. I will be using the Northwind database in my article which, is installed by default for SQL SERVER 2000 and SQL SERVER 7 databases. The code below is used to populate the GridView control. private void BindData() { string connectionString = "Server=localhost;Database=Northwind;Trusted_Connection=true"; SqlConnection myConnection = new SqlConnection(connectionString); SqlDataAdapter ad = new SqlDataAdapter("SELECT P

DHTML ToolTip with Calendar Control

Introduction: In one of my previous articles I talked about how you can effectively use DHTML with Asp.net to make cool tooltip. In this article I will show how you can use the same DHTML tooltip with the calendar control. Getting Started: The first thing you need to do is to download the DHTML script from www.dynamicdrive.com. You can download the script from this url http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm. After download the script just place the required css in the head section of the page and the script in the body of the page. Screen shot of what we are going to do: Here is a screen shot of what we are going to do in this article. As you can see that when you place your cursor over any date in the calendar it pops out the description in the DHTML box. The Code: The code is pretty simple. First you need to pull all the information from the database to your dataset or any other collection. private DataSet GetArticles() { s

Creating the CAPTCHA Functionality

Introduction : According to wikipedia , CAPTCHA ( "Completely Automated Public Turing test to tell Computers and Humans Apart") is a challenge response test which is used to check that if the user is human or not. CAPTCHA is used exclusively in applications where the user input is required. These applications include Blogs, Forums and Portals. In this article I will demonstrate how to create a simple webpage that uses CAPTCHA functionality. The CreateImage Method : The first task is to create an image and put it on the screen. For that I have created an ASP.NET page named CaptchaControl.aspx . The CaptchaControl.aspx page will be responsible for displaying the image to the user. Let’s take a look at the following code which generates the image. private void CreateImage() { string code = GetRandomText(); Bitmap bitmap = new Bitmap (200,150,System.Drawing.Imaging. PixelFormat .Format32bppArgb); Graphics g = Graphics .FromImage(bitmap); Pen pen = new

Displaying Hierarchical Data in the DropDownList

Introduction : Most of the web applications display hierarchical data. There are numerous ways for presenting the hierarchical data in which, most common is to use the Tree control. Although, the Tree control serves a good purpose for displaying the hierarchical data but in some scenarios we have to find an alternative solution. In this article I will demonstrate how you can use a simple ASP.NET DropDownList control to display hierarchical data. Database and Stored Procedure: In this article I will be using the Northwind database which, is installed by default for SQL SERVER 7 and SQL SERVER 2000 databases. I have added a new stored procedure which returns multiple record sets. The first record set contains the categories and the second one contains the products. Populating the DropDownList: The next step is to populate the DropDownList with the data from the Northwind database. For, this purpose I have created a BindData

Bread Crumbs in ASP.NET 2.0

Introduction: Bread Crumbs are not considered a good appetizer but it is a valuable feature introduced in ASP.NET 2.0. Bread Crumbs allows you to view your current location in the website. This means if you are in the horror movies section of the website then it will indicate that you are indeed in the horror movies section by presenting the hierarchical view of your position. By using Bread Crumbs you can navigate back and forth in the categories. In this article I will demonstrate that how you can use a Bread Crumb in your web application. Understanding the Scenario: Let's first understand the scenario before talking about the implementation of the application. Suppose you are building a website that will contain information about movies and books. Each of the category can have sub categories. Movies can be comedy or horror and books can be fiction or horror. In your application you might have different folders for each of the category. Take a look at the screen shot below which