Posts

Showing posts from September, 2012

ASP.Net State management

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

How to remove a persistent cookies before Expiration time ?

How to remove a persistent cookies before Expiration time ? Cookies are the small pieces of information that are stored in client system or browser memory and helped as client site state management for an web based application. Generally we can have two types of cookies  Persistent Cookies Non Persistent Cookies Persistent Cookies :   also known as  permanent cookies , which is stored in client hard - drive until it expires . persistent cookies should have set with expiration dates . Sometimes its stays  until the user deletes the cookie. Persistent cookies are used to collect identifying information about the user from that system. Non Persistent Cookies : This can be called as Temporary Cookies . If there is no expires time  defined then the cookie is  stored in browser memory . Therefore there is no difference between modifying persistent or non-persistent cookies.  Only difference between them are Persistent cookies should have an Expatriation time defined withi

Disabling button when performing some operation in ASP.NET

Image
Disabling button when performing some operation in ASP.NET   In ASP.NET Web Application when we submit some button to process information in server side, we can disable the button as long the server performing the operation and enable the same one response is back. Most of the developer use Button Enable and Disable properties to enable and disable the button. But as an good practice we can use Page.ClientScript.GetPostBackEventReference to achieve the same. Button1.OnClientClick = ClientScript.GetPostBackEventReference(Button1, "") + "; this.value='Processing...';this.disabled = true;"; To do a quick test, you can write the below code block protected void Page_Load(object sender, EventArgs e) { Button1.OnClientClick = ClientScript.GetPostBackEventReference(Button1, "") + "; this.value='Processing...';this.disabled = true;"; } protected void Button1_Click(object sender, EventArgs e)

How EnableViewStateMAC Makes ViewState Secure

Image
How EnableViewStateMAC Makes ViewState Secure ? The ASP.NET ViewState is a client side state management mechanism. The ViewState is stored in a hidden field with an ID __VIEWSTATE . Typically, stored ViewState information looks like: ViewState value looks likes an encrypted string. This is nothing but a Base64 encoded string, and is not an encrypted string. So it can be easily decoded. The main reasons for using Base64 encoding are as follows: Base64 makes a string suitable for HTTP transfers It makes it a little harder to read But people often get confused that this is an encrypted string. Let us try to decode the string using ViewState Decoder (a nice tool created by Fritz Onion). After decoding the string, we can see the exact data that is stored inside the ViewState.  You can write a few lines of code to decode the text and you will get the actual View State information. By default, ViewState is serialized into a Base-64 encoded string. On postback,

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

Image
How to expand specific Tree View Node programmatically in ASP.NET ? ASP.NET TreeView control is a server side control for displaying data in a hierarchical formats. TreeView  contains multiple nodes and sub nodes. Many times we bind a large number of data with tree view for users to navigate data, pages, or displaying any other details information. If there are many nodes and sub nodes in TreeView, sometime  it’s quite difficult for a user  to find out a specific nodes. On that kind of situation we can give a functionally to user so that they can search for the tree node and can be expand automatically if its found. In this case you can use FindNode() method to find a particular node and then use Expand() method to expand that particular node.  FindNode() take node name as argument and return TreeNode if it’s found. You may even use ExpandAll() method to expand all the subsequent child nodes. Expanding Specific Node using Expand() Method [sourcecode l

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

Image
How to Display “Yes” or “No” Instead of Checkbox while binding Boolean value with GridView ? If you are binding some data source in grid view which having any field type of Boolean then Grid View Rendered it as “Checkbox” . But sometime we may required to display either Yes/ No or “1/0” instead of Checked/ Unchecked Text Box.   Here is an quick tip which described how you can override the checkbox to your required  value in  GridView RowDataBound events. Let’s consider you have a simple class “Student” with some student records. [sourcecode language="csharp"] /// <summary> /// Student Class /// </summary> public class Student { public int Roll { get; set; } public string Name { get; set; } public bool Status { get; set; } } /// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event

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

Image
Display custom messages or images when there is no records in GridView Data Source This is a very frequent requirements to display Custom Messages or Images when there is no records in Grid View. I found people used custom code to achieve this. But ASP.NET Gridview having some inbuilt features to do the same.   You can use EmptyDataTemplate using GridView to display any custom message or Images or even web controls to add new records or whatever you want as per your requirements. As shown in above image, I have show 3 different types of custom option ( Notation 3, 4, and 5 ) that you can display if you have no records in gridview .   Let’s have quick look into code snippet for displaying custom message if there is no records [sourcecode language="csharp"] <asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#CC9966" BorderStyle=&quo

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

Image
Displaying Custom Messages / Images with NULL Value in ASP.NET GridView When we  bind some data source with GridView which contains some fields with NULL value,  ASP.NET renders them as Blank. Sometimes developers use GridView_RowDataBound() to override the NULL value with proper message. But Instead of overriding the value, we can use NullDisplayText to display proper message when the value for that particular field is NULL . Once we mentioned NullDisplayText=”No Data” for every field for that Bound Filed which having NULL value will be replace by “No Data” Even we can customize the Text with HTML Formatting as shown in below. One more interesting point is, we  can also display Images for NULL Value S agar S B hanushali

1 - How to change GridView column alignments for dynamic data source

Image
1 - How to change GridView column alignments for dynamic data source ?   By Default ASP.NET GridView Columns has left alignment text. We can use GridView ItemStyle property with either of GridView BondField or Template Field to change the default alignments. GridView properties, ItemStyle-HorizontalAlign having few set of values, using  which we can change the alignments. Above customization is true when you are using Bound Field or Template Field for binding the data . But If you want to customize the same set alignments for data source which are directly binding with GridView you have to use Gridview_RowDataBound or Gridview_PreRender methods . Let’s say you are binding below set of records directly with gridview [sourcecode language="csharp"] List<Employee> employees = new List<Employee> { new Employee{ID=1, Name="Employee 1", Address="Address 1" }, new Employee{ID=2, Name="Employee

Smartphone Apps

Image
Free Android Apps: Download 40+ Cool Apps For Your Smart Phone Although Android Market is not as popular as the iPhone App Store, Google is still giving Apple a run for their money. With the popularity of Android OS on the rise, and with all the new smart phones coming on the scene, developers are scrambling to come up with new and useful apps for Android Market. In this post you will find my picks for some of my favorite free Android apps. You will see everything from social to news to gaming apps. Hopefully by viewing this post you will discover some free apps that you have never seen or used before. Enjoy! Twitter Follow your interests: instant updates from your friends, industry experts, favorite celebrities, and what’s happening around the world. Get short bursts of timely information on the official Twitter app for your Android phone. Vevo The wait is over!! The #1 online destination for music videos is now on your Android device. VEVO’s fr