Monday, April 23, 2012

How to view generated source by AJAX (or by JS)



One of the challenging things about debugging an AJAX application is that it isn't obvious how to view the html source that is being rendered by the browser after you have made modifications to it via an AJAX callback.  If you use the browser's built-in View Source command then it will show you the source that was used to render the original page, but it will not include any modifications made via javascript/AJAX calls.

If you are trying to view the generated source in Firefox, the simplest way is to first download and install the WebDeveloper extension   Then go to the View Source menu item and select "View Generated Source".
To view the generated source in IE you can type the following in the address bar


Monday, April 9, 2012

ASP.NET Profile Properties Overview

In many applications, you want to store and use information that is unique to a user. When a user visits your site, you can use the information you have stored to present the user with a personalized version of your Web application. Personalizing an application requires a number of elements: you must store the information using a unique user identifier, be able to recognize users when they visit again, and then fetch the user information as needed. To simplify your applications, you can use the ASP.NET profile feature, which can perform all of these tasks for you.

The ASP.NET profile feature associates information with an individual user and stores the information in a persistent format. Profiles allow you to manage user information without requiring you to create and maintain your own database. In addition, the ASP.NET profile feature makes the user information available using a strongly typed API that you can access from anywhere in your application.

You can store objects of any type using profiles. The profile feature provides a generic storage feature that allows you to define and maintain almost any kind of data while still making the data available in a type-safe manner.

You configure the profile feature by defining a list of properties whose values you want to maintain. For example, you might want to store the user's postal code so that your application can offer region-specific information, such as weather reports. In the configuration file, you would define a profile property named PostalCode. The profile section of the configuration file might look like the following:

  

When the user enters a postal code, you set a "profile" property to store the value for the current user, as in the following example:
Profile.PostalCode = txtPostalCode.Text;
 
When you want to use the value, you can get it in much the same way that
 you set it. For example, the following code example shows how to call 
an imaginary function named GetWeatherInfo, passing it the current user's postal code as stored in a profile: 

weatherInfo = GetWeatherInfo( Profile.PostalCode );
 
Please refer this MSDN article for more details.