Sunday, October 24, 2010

Gridview RowEditing or RowDeleting event fires twice problem

When working with ASP.Net Gridview control's RowEditing or RowDeleting events, it fires twice if image is used in Edit or Delete CommandField. Many ASP.Net developers face this problem while working with Gridview controls. There is many post in different forum on this problem.

To solve this problem convert CommandField to TemplateField and add an ImageButton to show your Edit or Delete image.

Example Code:

<asp:TemplateField HeaderText="Edit">
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/Image/admin/edit.gif" Text="Edit" />


Tuesday, September 7, 2010

Introduction to Balanced Scorecard(BSC)

The balanced scorecard (BSC) is a strategic planning and performance management tool. It was originated by Drs. Robert Kaplan (Harvard Business School) and David Norton as a performance measurement framework. This added strategic non-financial performance measures to traditional financial metrics to give managers and executives a more 'balanced' view of organizational performance.
The balanced scorecard has evolved from its early use as a simple performance measurement framework to a full strategic planning and management system. It provides a framework that not only provides performance measurements, but helps planners identify what should be done and measured. It enables executives to truly execute their strategies.
 It is extensively used in business and industry, government, and nonprofit organizations worldwide to align business activities. It improves internal and external communications, and monitor organization performance against strategic goals.
It is perhaps the best known of several such frameworks.  It was widely adopted in English speaking western countries and Scandinavia in the early 1990s.
The four "perspectives" proposed were:
Financial: encourages the identification of a few relevant high-level financial measures. Timely and accurate funding data will always be a priority, and managers will do whatever necessary to provide it. In fact, often there is more than enough handling and processing of financial data. With the implementation of a corporate database, it is hoped that more of the processing can be centralized and automated.
Customer: Recent management philosophy has shown an increasing realization of the importance of customer focus and customer satisfaction in any business. These are leading indicators: if customers are not satisfied, they will eventually find other suppliers that will meet their needs.
Internal Business Processes: This perspective refers to internal business processes. Metrics based on this perspective allow the managers to know how well their business is running, and whether its products and services conform to customer requirements (the mission).
Learning and Growth: This perspective includes employee training and corporate cultural attitudes related to both individual and corporate self-improvement. In a knowledge-worker organization, people -- the only repository of knowledge -- are the main resource. In the current climate of rapid technological change, it is becoming necessary for knowledge workers to be in a continuous learning mode.

Balance Scorecard

Monday, July 26, 2010

Creating client script dynamically

In many cases, you can create the client script for your page declaratively, usually as a script block. However, you can also create client script dynamically. This is useful if the script depends on information that is available only at run time. For example, you might insert client script into a page that addresses a server control whose name (ID) is not known until the application runs, or you might create script that depends on values that you get from a user.
You can create and insert client script dynamically into a rendered page by calling methods of the ClientScriptManager class, such as the following:
·         RegisterClientScriptBlock, which inserts a script block at the top of the rendered page.
·         RegisterStartupScript, which inserts a script block at the end of the rendered page.
The following example shows how to add dynamically generated client script to the page. The code checks whether a check box named checkDisplayCount is selected. If so, the code performs the following tasks:
·         It creates a client script function that uses a span element to display the character count in a TextBox control named TextBox1.
·         It adds a client event to the TextBox control.
·         It generates the span element.
The code assumes that the page contains a check box named checkDisplayCount whose AutoPostBack property is set to true and a PlaceHolder control named PlaceHolder1.

void Page_Load(object sender, EventArgs e)
        String scriptText = "";
        scriptText += "function DisplayCharCount(){";
        scriptText += "   spanCounter.innerText = " + 
            " document.forms[0].TextBox1.value.length";
        scriptText += "}";
           "CounterScript", scriptText, true);
        TextBox1.Attributes.Add("onkeyup", "DisplayCharCount()");
        LiteralControl spanLiteral = new 


Monday, June 21, 2010

ASP.Net State management

What is State Management?
State management is the process by which you maintain state and page information over multiple requests for the same or different pages.
ASP.NET includes several options that help you preserve data on both a per-page basis and an application-wide basis.

Types of State Management
There are two basic types of State Management:
1.       Client-Based State Management
2.       Server-Based State Management
Client-Based State Management:
Client based state management techniques stores data on the client in various ways. Client based state management techniques are:
A.      View state
B.      Control state
C.      Hidden fields
D.      Cookies
E.       Query strings

View state:
The view state represents the state of the page when it was last processed on the server. It's used to build a call context and retain values across two successive requests for the same page. By default, the state is persisted on the client using a hidden field added to the page and is restored on the server before the page request is processed.
If the amount of data stored in the ViewState() property exceeds the specified value in the MaxPageStateFieldLength() property, multiple hidden fields are used to store View state data.
a)      Server resources not required.
b)      Simple implementation
c)       automatic retention of page and control state
d)      Enhanced security features. The values in view state are hashed, compressed, and encoded for Unicode implementations.

a)      Scope is limited to only single page.
b)      Performance. The view state is stored in the page itself, so increase the page size.
c)       Security. The view state is stored in a hidden field on the page. Although view state stores data in a hashed format, it can be tampered with.

Control state:
If you create a custom control that requires view state to work properly, you should use control state to ensure your control work properly though developers disable view state. The ControlState() property allows you to persist property information that is specific to a control and cannot be turned off like the ViewState() property.
a)      Server resources not required.
b)      Reliable. Because control state can not be turned off like ViewState.

a)      Some programming is required.
Hidden Fields:
A hidden field acts as a repository for any page-specific information that you want to store directly in the page. ASP.NET allows you to store information in a HiddenField control, which renders as a standard HTML hidden field. A hidden field does not render visibly in the browser.
You must submit the page using an HTTP POST command in order for hidden-field values to be available.

a)      Server resources not required.
b)      Simple implementation
c)       Widespread support.

a)      Potential security risk.
b)      Performance. The hidden fields are stored in the page itself, so increase the page size.
c)       Does not support rich data types to store.
A cookie is a small amount of data that is stored either in a text file on the client file system or in-memory in the client browser session. Browser sends with cookies values with every page request to the same server. Cookies can be temporary or persistent.

a)      Server resources not required.
b)      Simple implementation
c)       Configurable expiration rules
d)      Data persistent.

e)      Size limitation: Most browsers support maximum 4096 bytes cookies.
f)       User configuration refusal: User can disable cookies in their browser.
g)      Security risk: Can be tempered.

Query strings:
A query string is information that is appended to the end of a page URL. Query strings provide a simple but limited way to maintain state information.  Some browsers and client devices impose a 2083 character limit on the length of the URL.
You must submit the page using an HTTP POST command in order for query string values to be available.
h)      Server resources not required.
i)        Simple implementation
j)        Widespread support.

k)      Size limitation: Some browser limits 2083 chars on the length of URLs.
l)        Security risk: Information is visible to the user.

Server-Based State Management:
Server based state management techniques store data in memory on the server.  Server based state management techniques are:
A.      Application state
B.      Session state
C.      Profile Properties

Application state:
Application state provides a method of storing data global to whole application. These data are visible to entire application and shared by all active sessions. That’s why Application state variables are global variables for an ASP.Net application.
m)    Simple implementation
n)      Application wide scope

o)      Application scope in case of Web Garden or Web Firm.
p)      Limited Durability of data.
q)      Requires server memory.

Session state:
Session state provides a method of storing session specific information that is visible only within the session.
r)       Simple implementation
s)       Session specific events
t)       Data can persists across multiple process

u)      Application scope
v)      Limited Durability of data.
w)    Requires server memory.