Generic Way to Bind Enum With Different ASP.NET List Controls

In this post I am going to explain how we can bind a Enum with ASP.NET List Controls. These comprise of four different types of control, CheckBoxList, DropDownList, ListBox and RadioButtonList. This is one of the common requirements during development to bind a Enum with List Control and challenge is when we need to bind the both text and value.
Let’s consider we have the blow Enum. Now I am going to bind it with all the above mentioned type List Controls.
image

Well, One of the easiest way that we can implement is by Enum.GetNames(Type enumType)which retrieves the name list of enumberation  and Enum.GetValues(Type enumType), which returns the list of values for each names .

Advertisements

10 ASP.NET Tips and Tricks

Here I am sharing 10 ASP.NET Tips and Tricks most of them related with Grid View Control

How to change GridView column alignments for dynamic data source ?

How to pass multiple values using GridView HyperLinkField ?

Displaying Custom Messages / Images with NULL Value in ASP.NET GridView

Display custom messages or images when there is no records in GridView Data Source

How to Display “Yes” or “No” Instead of Checkbox while binding Boolean value with GridView ?

How to expand specific Tree View Node programmatically in ASP.NET ?

Run ASP.NET Web Application from Command Prompt

 How EnableViewStateMAC Makes ViewState Secure ?

 Disabling button when performing some operation in ASP.NET

 How to remove a persistent cookies before Expiration time ?

To know more Tips and Tricks Follow @dailydotnettips and visit http://dailydotnettips.com

On a side note,  I would like to congratulate couple of my friends, first a key community contributor on WCF, Dhananjay Kumar  for renewing  Microsoft MVP – Connected System again for year 2011. He blogs at  http://debugmode.net/ and his twitter id @debugmode_ .  and second one  Krishna Chaitanya T for Microsoft MVP – Internet Explorer . He is a Web Geek, do lots of research on web technology. He blogs at http://www.novogeek.com/ and his Twitter ID @novogeek . Good job guys !!

Creating a simple Context Sensitive Help for ASP.NET Controls using jQuery

In this blog post I am going to explain how we can create a simple  Context Sensitive Help for ASP.NET Controls using jQuery. This has been done based on the selection of a controls in a ASP.NET Web Form. On control selection / focus  jQuery Loads a  HTML Content from a remote file, then it’s apply the filter based on the control id and inject the filtered content into a predefined placeholder  with in the DOM Hierarchy.

ASP.NET Custom Repeater Control with EmptyTemplate, ShowHeaderWhenEmpty,ShowFooterWhenEmpty,ShowCount Properties

If you have worked with ASP.NET GridView Control you must be aware of GridView.EmptyDataTemplate Property  which Gets or sets the user-defined content for the empty data row when a GriimagedView control  data source has no records. Similarly ShowHeaderWhenEmpty property allows you to show or hide the Header row when there is no records. These are the really good and very frequent required properties. Now, if you are working with the Repeater Control, it doesn’t have any direct features which enables you to set user define content when data source is empty. In this blog post I will discuss how we can create a custom ASP.NET Repeater control with support of EmptyTemplate along with few more important features.

15 Tips from Daily .NET Tips

Daily .NET Tips is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET. Here I am sharing few frequently required tips which are already published over there.

  1. How to count number of active session for State Server Session Mode ?
  2. How to use Runtime Objects in Watch Window during debugging in Visual Studio ?
  3. How to calculate Session data size for SQL Server session mode?
  4. Know when your application pools recycling in IIS 7.5 – Log an entry in Event Viewer while recycling
  5. Workaround For Non Serializable Types
  6. How EnableViewStateMAC Makes ViewState Secure ?
  7. Different approaches to Casting
  8. How to Display “Yes” or “No” Instead of Checkbox while binding Boolean value with GridView ?
  9. Changing Variables Display Format in Watch Window
  10. Getting Added And Deleted Items In A List Using LINQ
  11. How to setup multiple startup projects in Visual Studio ?
  12. Displaying Custom Messages / Images with NULL Value in ASP.NET GridView
  13. ASP.NET Validation Control with Images Notification
  14. How to expand specific Tree View Node programmatically in ASP.NET ?
  15. Display custom messages or images when there is no records in GridView Data Source

For more tips please visit  http://dailydotnettips.com and follow @DailyDotNetTips at Twitter

Thanks !

Run ASP.NET Web Application from Command Prompt

Visual Studio has its own integrated ASP.NET Runtime engine, which helps to run any ASP.NET web application with in Visual Studio.  While running application from Visual Studio, you must have seen a popup notification in System Tray (As shown in below image) , which is notification of ASP.NET Development Server.

image

This ASP.NET Development Server is nothing but a executable file (WebDev.WebServer) which used by Visual Studio to execute you web application when it’s running in the context of Visual Studio.  You can find the executable file at <\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0> . This folder contain two different executable

  • WebDev.WebServer20.EXE
  • WebDev.WebServer40.EXE

WebDev.WebServer20 is targeted to CLR 2.0, which means all the ASP.NET Application which are targeted till FW .NET 3.5 will be taking care by WebDev.WebServer20.EXE and WebDev.WebServer40.EXE for ASP.NET 4.0 based application.

Now, let’s see how we can use these executable to run an ASP.NET 4.0 Application with out using Visual Studio. Surprised smile

Download PPT – “ASP.NET Request Processing Internals” – Microsoft User Group Hyderabad Community Meet – 26 Feb 2011

Yesterday I delivered  1 hour session on “ASP.NET Request Processing Internals”  at Microsoft User Group Hyderabad (MUGH).  This was an half day event and organized at Microsoft Campus , Building 3 MPR Halls , Gachibowli, Hyderabad. I delivered the first session Slide1on ASP.NET Request processing Internals where I talked about how request processing happens in IIS level to ASP.NET Application Level.  In this presentation I talked about how ASP.NET Application runs with in VS IDE ,  then moving to IIS, Different Components of IIS like HTTP.SYS, SVCHOST, WWW Publishing Services, WAS along with there roles in ASP.NET Request processing. I have also covered the key concepts like Worker Process, Application Pool, Web farms and web garden. Then I talked about how requests flow from HTTP.Sys, to WWW Services, WAS and How things happens with Worker Process . I have also talked about HTTP Pipeline and ASP.NET Page life cycle was the last one.

Download Presentation

How to make ViewState secure in ASP.NET ?

The ASP.NET ViewState is a client side state management.  ViewState is stored in hidden field with ID named __VIEWSTATE. Typically, stored ViewState information  looks as below:

image 

Now let us look at the value. It looks likes an encrypted string. This is nothing but Base64 Encoded string and it is not an encrypted string.  So it can be easily decoded.

The main reasons for making it Base64 encoding are as follows:

1.  Base64 makes a string suitable for HTTP transfer

2. It makes it a little harder to read .

But people often get confused that this is an encrypted string.

When we can use HttpContext.Current.Items to stores data in ASP.NET?

To answer this question In a single statement, you can use HttpContext.Current.Items for very short term storage. By Short term storage means, this data is valid for a single HTTP Request.  There are many confusion around regarding storing data in HttpContext.Current.Items and storing data in Session variable. In this blog post I am going to describe what are the different scenarios where we can use HttpContext.Current.Items and what is the exact difference with session variable.

Items collections of HttpContext is and IDictionary key-value collections and that are shared across a single HTTPRequest. Yes, HttpContext.Current.Items  valid for  a single HTTPRequest.  Once after processing, server  information  is sent back to the browser, the variables that were set in the Items[] collection will lost. Where as for Session Variable, information valid for multiple request as this is user specific. The session variable only  expires either on Session Time Out or explicitly clear the values.

How to Use ASP.NET “Property Pages” to create or host a Silverlight application in ASP.NET Site ?

While creating a Silverlight application in Visual Studio 2010, after providing the application name, IDE asked for whether you want to host the Silverlight application in a new ASP.NET web site or not. If you select the “Ok” button , Visual Studio will create a ASP.NET Site to host the corresponding Silverlight Application. So whenever you will run the Silverlight application, ASP.NET site will automatically host the Silverlight file  But suppose you have an existing Silverlight Application and you want to host it in a ASP.NET site in a similar way that New Silverlight project does  or you want to add a new Silverlight application which will automatically host inside your current asp.net web site? Do you know we can easily achieve this using “Property Pages” of an ASP.NET Application. Let’s explore how we can do that.

How to use IIS Manager to get Worker Processes (w3wp.exe) details information ?

In one of my previous blog post, Identifying Worker Process (w3wp.exe) – IIS 6.0 and IIS 7.0 for Debugging ASP.NET Application  –  I have explained about how we can identify the list of currently running worker process  using command prompt while we need to attach process from visual studio . But do you know for IIS 7.0 and IIS 7.5 we can get the worker process (w3wp.exe) details like Application Pool name, Process ID, CPU Usages from IIS Manager itself. Even you can get details of each worker process for a “Web Gardenscenarios.  So when you need to attach some process for debugging from Visual studio, Instead of going to command prompt, you can easily identify the worker process Id from IIS itself.   

2 

What is the difference between Web Farm and Web Garden ?

I have been asked this question many times by different readers of my blog. They wanted to know about the fundamentals of Web Farms and Web Garden. In this blog post, I am going to explain the what is the exact difference between web farm and web garden, what are the advantages and disadvantages of using them. I have also described how to create web garden in the different version of IIS.

Overview :

Visual Studio is having its integrated ASP.NET engine which is used to run the ASP.NET Web application from Visual Studio. ASP.NET Development Server is responsible for executing all the request and response from the client. Now after the end of development, when you want to host the site on some server to allow other peoples to access, the concept of web servers comes in between.  A web server is responsible for responding to all the requests that are coming from clients. Below diagram showing the typical deployment structure of an ASP.NET Web application with a single IIS.

2 Clients request for resources and IIS Process the request and send back to clients. If you want to know more details on How IIS Process the request, please read one of my article over “How IIS Process ASP.NET Request ?”.

Web Farm :

This is the case, where you have only one web server and multiple clients requesting for the resources from the same server. But when there are huge numbers of incoming traffic for your web sites, one standalone server is not sufficient to process the request.  You may need to use multiple servers to host the application and divide the traffic among them.  This is called “Web Farm.” So when you are hosting your single web site on multiple web server over load balancer called “Web Farm.” Below diagram showing the over all representation of Web Farms.

 Web Farms

How to remove Hyperlink from ASP.NET TreeView Control Nodes ?

ASP.NET Tree view control rendered as HTML Table – TR –TD  elements. Each of the node are been represented as hyperlinks. Some times you may not want that fields as hyperlink and you want to be those nodes should be represent as static text. Many of the developer did the same using  font style or css style change of the node, but it can be done very easily.  In this small blog  post I am going to describe how you can represent a tree view node as simple text instead of hyperlink.

This can be done very easily using Tree Nodes, SelectionAction properties. SelectionAction having 4 different values, they are.

3

Select is the default option which marked node as hyperlinked and on selection of the node, it raised SelectedNodeChanged event.  For Expand Option, TreeNodeExpanded event will be raised while expanding the node. “SelectExpand” raised both the SelectedNodeChanged and  TreeNodeExpanded  events. Now if you don’t want to make the node as simple text, just change the SelectionAction properties to “None”.

1

IIS Articles Archives

In this blog post I have going to list out all of my IIS articles that I have published over last few years. Why I am going to do such post ? Because, I have been asked many question on IIS and different debugging options related with IIS and ASP.NET Applications by many readers. Many times I have had given reference of my different articles.   This post will be the single reference for all of those articles. In this blog post I have given link  and small overview of all of my IIS articles, so that I can refer a single articles to who ever wants to learn about IIS.

1. Beginner’s Guide : Exploring IIS 6.0 With ASP.NET 

This article describes details of IIS configuration, Virtual Directory creation, Application Pool Creation, Application Pool settings, IIS Request processing for ASP.NET .

beginn1