Friday 29 January 2010

Binding to Data Using a Data Source Control

Data source controls greatly expand the capabilities of data-bound controls such as the GridView, FormView, and DetailsView controls. By working together, data source controls and data-bound controls let you retrieve, modify, page, sort, and filter data from different data sources with little or no code.

Binding by Using the DataSourceID Property

You can work with data in a data-bound control by binding the data-bound control to a data source control such as a LinqDataSource, ObjectDataSource, or SqlDataSource control. The data source control connects to a data source such as a database, entity class, or middle-tier object and then retrieves or updates data. The data-bound control can then use this data. To perform the binding, you set the data-bound control's DataSourceID property to point to a data source control. When a data-bound control is bound to a data source control, little or no additional code is required for data operations. The data-bound control can automatically take advantage of the data services provided by the data source control.

In earlier versions of ASP.NET, data-bound controls were bound to data by using the DataSource property. This required that you write code to handle operations such as displaying, paging, sorting, editing, and deleting data. Although you can bind controls to data by using the DataSource property (and use existing code), you can also performing data binding by using the DataSourceID property instead. In general, using the DataSourceID property provides more automatic functionality than using the DataSource property.

Follow this link to read more
http://msdn.microsoft.com/en-us/library/ms228089.aspx

Thursday 28 January 2010

Setting a Default Browser for Visual Studio

1. Open a WebForm file in VS (anything ending in .aspx will do)
2. Select the "Browse With..." option from the File menu
3. Select your preferred browser from the list and click the "Set as Default" button

Now opening, browsing, or debugging a WebForm from within Visual studio will open the file in the specified browser rather than my system default.

Wednesday 27 January 2010

jQuery.scrollTop( )

Gets the scroll top offset of the first matched element. This method works for both visible and hidden elements.

The vertical scroll position is the same as the number of pixels that are hidden from view above the scrollable area. If the scroll bar is at the very top, or if the element is not scrollable, this number will be 0.

$(window).scrollTop() will give vertical scroll position of the current window.

jQuery.trim()

Remove the whitespace from the beginning and end of a string.

$("button").click(function () {
var str = " lots of spaces before and after ";
alert("'" + str + "'");

str = jQuery.trim(str);
alert("'" + str + "' - no longer");
});