Pages

Auto complete textbox using jQuery

Here I am going to show simplest way to write auto-completer using jQuery ajax. Code has sufficient comments and hence is self explanatory. So I will not explain it any further, simply follow the steps as shown below.

Get QueryString values using JavaScript

In asp.net, we retrieve query string values using QueryString collection property of HttpRequest class which in turn is exposed as a Request property of Page class. So in asp.net we can get query string value using syntax like Page.Request.QueryString[index | "key_name"] and so on. However, many times, we also need to access these query string values in client script, say, JavaScript.

RegisterStartupScript vs RegisterClientScriptBlock in asp.net

Both of these are methods of ScriptManager class. Instance of ScriptManager class is exposed as "ClientScript" property of the page. These methods are used to dynamically insert client script into the webpage at runtime. If both can insert client script at runtime, then what's the difference between the two? Note that Page class also has these methods however they have been marked as deprecated now.

Persist gridview row selection during pagination

Gridview is most commonly used control for displaying tabular data from database. However most of the times, we need to perform bulk operations on multiple rows and for this we provide user with extra column containing checkboxes for selecting rows. User selects one or more records (rows) and performs bulk operations.

Checkbox list validation using custom validator in asp.net

Here I am going to show a simple way of checking if any of the checkbox list items is selected or not. It is quite common scenario wherein a form contains checkbox list and that selecting at least one of the options from list is mandatory. Surely RequiredFieldValidator is not going to work in this case. So we will be using CustomValidator for validation.

Remove scrollbars from textarea in internet explorer

One of the key concerns in web development is to make your website look consistent in all the browsers, however, there are large no of browsers available. Still, it is important to have consistent look and feel of website in most widely used browsers like Chrome, Firefox, Internet Explorer, Safari, and Opera. (I have mentioned these in descending order of popularity, source: http://www.w3schools.com/browsers/browsers_stats.asp).

Passing multiple params to Javascript using Eval in asp.net

I have seen lot of people struggling when it comes to passing more than one parameter to JavaScript function from within any asp.net databound controls. Hence decided to blog it here. I am not going to explain much in this post as there's hardly anything that I can say!

What is SET NOCOUNT in SQL

SET NOCOUNT is used to improve performance, especially that of Stored procedures and Triggers. When you create new stored procedure or trigger on a table, SQL Server Management Studio (SSMS) generates a template.

Accordian control not showing up after databinding! (AjaxControlToolkit)

In this post I am going to point out the issue related with binding data to ajax Accordian control. For the first time (long back!) when i used Accordian control for displaying data from database, I simply could not do it. I felt it would just be as straight forward as binding Gridview, ListView etc, but I was wrong!

Difference between Const and Readonly in C#

It is quite obvious to get confused between the two or to exactly understand what are the differences between them and how they work. Using either of them in place of each other (a field cannot be const as well as readonly at a same time) without understanding can put you in trouble at later stage. So lets first look at the differences:

Understanding access modifiers in C#

I am writing this post for those who know what access modifiers are, but have some difficulties understanding exact differences, especially internal and protected internal. So i will explain the same with very simple code.

SqlDataSource - Advanatges & Disadvantages

I have seen many people asking about whether they should go with SqlDataSource or write the custom code for databinding. Or when should they follow either of the approaches. So i decided to list down few (in fact very few, but definitely major ones!) advantages and disadvantages of using SqlDataSource control, as i strongly believe writing code for databinding is the best approach.

Customize ValidatorCallout extender control

Today i am going to show how can a ValidatorCallout can be themed. Link says, for customizing ValidatorCallout "user would have to set the CssClass property to the name of the CSS style and define the styles for the individual classes so that the various elements in a ValidatorCallout control can be styled accordingly".

Split function in SQL

Its a common requirement to split delimited string and get a list of values. However, there is no built-in Split function in SQL.

HTML table search using JavaScript

Its a common practice to display large data using table elements. Moreover, many a times its obvious to provide facility to search through the displayed data especially when there are hundreds or thousands of rows and columns. One cannot expect users to keep scrolling vertically/horizontally for finding information of their interest.

Validate Gridview selection using Javascript

Its a common scenario where we provide checkbox in each row of gridview for selecting that record. And there are actions which need to be taken on selected records in gridview. Typical example would be an admin page where you display list of registered users and give facility to activate, deactivate, delete registrations.

Popup using JavaSript and CSS

Here is a simple way by which you can display a popup with faded background effect using JavaScript and CSS. No third party toolkit or controls required! Faded background will not be responsive while popup is being displayed.

_doPostBack function in javascript - asp.net postback mechanism

Big question!!! What is __doPostBack function in javascript and what it does? In asp.net all the web server controls except Button and ImageButton (discussed at the end) use javascript __doPostBack function to trigger postback. This behavior is known as asp.net postback mechanism.

Display data from SQL database using GridView

Here i will explain how to display data from SQL database using asp.net GridView control.

Define GridView

You can either define GridView by typing or simply by dragging the same from toolbox in Visual Studio (Referred as VS hereafter) . Go to Toolbox > Data and drag the control on the page (You can also double click on the item)
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>

Check if page was invoked by Server.Transfer or PostBackUrl

In my earlier post i explained about Server.Transfer and PostBackUrl (cross-page posting) and the differences between them. Here i will show how to check which one invoked the current page.

Server.Transfer, Response.Redirect and PostBackUrl


When i was beginner i always struggled with these techniques. Always wondered what are the exact differences between Response.Redirect, Server.Transfer & PostBackUrl, and most importantly "when should one be used over other!?" Let me explain each of these in details.

Validation controls in asp.net

Here i am going to explain one of the most important and useful set of controls, validation controls in asp.net (here onwards i will refer them as validators, for the sake of simplicity).