studio NETSOULS

Applying Web To Your Business

First off, the code-behind model has changed. In the @Page directive, accessing your code behind is accomplish via the CodeFile attribute instead of the Code behind or Src attribute. Also much of the used to DataGrid properties have changed, as seen below:

.NET 1.1 DataGrid

.NET 2.0 GridView

CurrentPageIndex

PageIndex

OnPageIndexChanged

OnPageIndexChanging

OnSortCommand

OnSorting

DataKeyField

DataKeyNames

SelectedItemStyle

SelectedRowStyle

ItemStyle

RowStyle

TemplateColumn

TemplateField

BoundColumn

BoundField

DataGrid.Items

GridView.Rows

DataGridItem

GridViewRow

DataGridItem (ItemIndex)

GridViewRow (RowIndex).Value

DataGridPageChangedEventArgs

GridViewPageEventArgs

DataGridSortCommandEventArgs

GridViewSortEventArgs

The CurrentPageIndex which gets or sets the index of the currently displayed page is now simply PageIndex. Setting up paging and sorting in the Gridview has changed from the OnPageIndexChanged and OnSortCommand methods to OnPageIndexChanging and OnSorting, respectively. The primary key field for the items displayed in the GridView has also changed from DataKeyField to DataKeyNames property.

Setting up row colors on the grid is no more SelectedItemStyle or ItemStyle but rather SelectedRowStyle and RowStyle. I guess this makes more sense since it is a row, anyway. The TemplateColumn class that displays custom content in a data-bound control is now TemplateField, and its partner the BoundColumn which represents a field that is displayed as text in a data-bound control is now called BoundField.

Next, in our code-behind, .NET 2.0 utilizes a new language feature known as a Partial. A Partial class is just that, a partial, incomplete definition of the class or structure. So all that is included in the partial class in only the code needed, such as event handlers and the like. .NET infers the control instances and it derives the events bound from the .aspx file during compilation. Notice in the code behind I didn’t have to declare the GridView or the OutputMsg controls there, as I did in the DataGrid version, neither did I need to include most of the Imports statements that were there before!

Another change in the framework went to the RegisterClientScriptBlock method, this now obsolete method needs to be ClientScript.RegisterClientScriptBlock (Type type, string key, string script) or in our code ClientScript.RegisterClientScriptBlock (Me.GetType(),”clientScript”, jsScript.ToString()).

As for implementing custom paging, this also has changed its class wording from DataGridPageChangedEventArgs to GridViewPageEventArgs.

In Short the main diffrence betbeen GridView and DataGrid is:
Sorting: In DataGrid code requires to handle the SortCommand event and rebind grid required. In case of GridView no additional code required.
Paging: In DataGrid requires code to handle the PageIndexChanged event and rebind grid required. In case of GridView no additional code required. It also supports customized appearance.
Data binding: Like GridView DataGrid cannot bind with new datasource control in ASP.NET 2.0. Updating data:  DataGrid requires extensive code to update operation on data. GridView  requires little code. Code like exceptions handling for database part.
Events: GridView supports events fired before and after database updates. In DataGrid less events supported as compared to GridView.

  • Currently 4 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Below is a table of the most common client side events in JavaScript. The Table is divided into three columns – the first lists the name of the event. The second contains a short description of the event, and the third lists all page objects, which support the given event.

Event Name

               Description

Supported by objects

onabort

The onabort event occurs when loading of an image is aborted.

image

onblur

The onblur event occurs when an object loses focus.

button, checkbox, fileUpload, layer, frame, password, radio, reset, submit, text, textarea, window

onchange

The onchange event occurs when the content of a field changes.

fileUpload, select, text, textarea

onclick

The onclick event occurs when an object gets clicked.

button, document, checkbox, link, radio, reset, submit

ondblclick

The ondblclick event occurs when an object gets double-clicked.

document, link

onerror

The onerror event is triggered when an error occurs loading a document or an image.

window, image

onfocus

The onfocus event occurs when an object gets focus.

button, checkbox, fileUpload, layer, frame, password, radio, reset, select, submit, text, textarea, window

onkeydown

The onkeydown event occurs when a keyboard key is pressed.

document, image, link, textarea

onkeypress

The onkeydown event occurs when a keyboard key is pressed or held down.

document, image, link, textarea

onkeyup

The onkeyup event occurs when a keyboard key is released.

document, image, link, textarea

onload

The onload event occurs immediately after a page or an image is loaded.

image, layer, window

onmousedown

The onmousedown event occurs when a mouse button is clicked.

button, document, link

onmousemove

The onmousemove event occurs when the mouse pointer is moved.

onmousemove is, by default, not an event of any object, because mouse movement happens very frequently.

onmouseout

The onmouseout event occurs when the mouse pointer moves away from a specified object.

layer, link

onmouseover

The onmouseover event occurs when the mouse pointer moves over a specified object.

layer, link

onmouseup

The onmouseup event occurs when a mouse button is released.

button, document, link

onreset

The onreset event occurs when the reset button in a form is clicked.

Form

onresize

The onresize event occurs when a window or frame is resized.

Window

onselect

The onselect event occurs when text is selected in a text or textarea field.

text, textarea

onsubmit

The onsubmit event occurs when the submit button in a form is clicked.

Form

onunload

The onunload event occurs when a user exits a page.

window

  • Currently 5 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

The current article is taken from http://blog.telerik.com

In some scenarios it is useful to encode and decode the URI. For example:

To avoid unexpected requests to the server, you should call encodeURIComponent on any user-entered parameters that will be passed as part of a URI. For example, a user could type "Thyme &time=again" for a variable comment. Not using encodeURIComponent on this variable will give comment=Thyme%20&time=again. Note that the ampersand and the equal sign mark a new key and value pair. So instead of having a POST comment key equal to "Thyme &time=again", you have two POST keys, one equal to "Thyme " and another (time) equal to again.

encodeURIComponent

Core Function:
Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character.

//Syntax
var encoded = encodeURlComponent(str);

encodeURIComponent escapes all characters except the following: alphabetic, decimal digits, - _ . ! ~ * ' ( )

decodeURIComponent

Replaces each escape sequence in the encoded URI component with the character that it represents.

Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine.

  • Currently 5 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

If you've worked on creating a Data Access Layer you know how frustrating it can be to determine the type of data your DAL will be handling. For that reason, creating a converter that works with generics or vica-versa can be the long term answer.

Alright, so for our applications we have a couple of forms that use the DataGridView control to display tabular data (kinda of a common scenario for many business applications). The data is returned from our services as an IList<T> in which we can just then bind directly to the grid by using the grid's DataSource property.  Pretty easy task...unless when it comes to data manipulations.

So, what we decided to was take the easy way out and that is convert our IList<T> to a DataTable object with the correct schema (for the primitive types) that our contained objects have.  Here's what we came up with:More...

  • Currently 4 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

I lot of times in our Business Object Model we use enums, these enum property could be a string, integer or a short value. While retrieving records from the database we need to set the property in the BOM to that of the enum value.

Here is one of those methods that you can never find when you're looking for it

   1: // suppose we have a enum
   2: enum PublishingStatus : short
   3: {
   4:     Draft = 1,
   5:     PendingApproval = 2,
   6:     Active = 3,
   7:     Archived = 4,
   8:     PendingDeletion = 5
   9: }
  10:  
  11: //set a default value
  12: PublishingStatusEnum CurrentPublishingStatus = PublishingStatusEnum.Draft;
  13: if (Enum.IsDefined(typeof(PublishingStatusEnum), Helper.GetShort(Reader["CurrentPublishingStatusId"])))
  14:     CurrentPublishingStatus = (PublishingStatusEnum)Enum.Parse(typeof(PublishingStatusEnum), Reader["CurrentPublishingStatusId"].ToString());
  15:  
  16: // suppose we have a string enum
  17: enum SiteColors
  18: {
  19:     Red,
  20:     Blue,
  21:     Orange
  22: }
  23:  
  24: //set a default value
  25: SiteColors SelectedColor = SiteColors.Red;
  26: if (Enum.IsDefined(typeof(SiteColors), Reader["SiteColor"].ToString()))
  27:     SelectedColor = (SiteColors)Enum.Parse(typeof(SiteColors), Reader["SiteColor"].ToString(),true);
  28: // we passed the last variable as true of ignoreCase
  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

About Us

studio NETSOULS is a complete IT services company, offering strategy, design, development and implementation of the total solution for your web and IT initiatives. The solutions we provide, enables businesses to leverage leading edge technology to gain sustainable competitive advantages in today's marketplace.

We specialize in designing, developing and deploying the next generation of IT solutions including e-business solutions Read more...

Tags

This will be shown to users with no Flash or Javascript.

Contact Us

My status

Quote of the Day

Men are disturbed, not by the things that happen, but by their opinion of the things that happen

- Epictetus

NutritionVista

www.NutritionVista.com

Archives


Advertisements


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Log in