Friday, June 15, 2012

JSON Parsing using JQuery

Takes a well-formed JSON string and returns the resulting JavaScript object.
  • version added: 1.4.1 

    usage  -- jQuery.parseJSON( json )

    json  --- The JSON string to parse.
Passing in a malformed JSON string may result in an exception being thrown. For example, the following are all malformed JSON strings:
  • {test: 1} (test does not have double quotes around it).
  • {'test': 1} ('test' is using single quotes instead of double quotes).
Additionally if you pass in nothing, an empty string, null, or undefined, 'null' will be returned from parseJSON. Where the browser provides a native implementation of JSON.parse, jQuery uses it to parse the string. For details on the JSON format, see http://json.org/.

Example:

Parse a JSON string.

var obj = jQuery.parseJSON('{"name":"John"}');
alert( obj.name === "John" );

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.
 

Tuesday, March 6, 2012

JSONView - Firefox addon

Today i came across a firefox plug-in for viewing JSON Data.
After installing this plug in you can see JSON data formatted and highlighted in browser.
Can download JSON View from below link..
https://addons.mozilla.org/en-US/firefox/addon/jsonview/

Free REST service can try after installing JSON View.
http://api.worldbank.org/countries?format=json
 

ASP.NET Web API

ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.

  • ASP.NET MVC includes ASP.NET Web API.
  • Choose either the Web Platform for Visual Studio 2010 or for Visual Studio 11, depending on which version you are running.
for samples , please visit -  http://www.asp.net/web-api/samples
for more details - http://www.asp.net/web-api

Monday, February 20, 2012

Single Page Application - ASP.Net

The ASP.NET Single Page Application (SPA) is a new feature in the ASP.NET MVC 4 beta preview. It provides a better end-to-end experience for building applications with significant client-side interactions using JavaScript.

   1. A set of JavaScript libraries for richer local interactions with cached data
   2. Additional Web API components for unit of work and DAL support
   3. An MVC project template with scaffolding to get started quickly



JavaScript Libraries

The JavaScript libraries include existing popular ones such as Knockout and History and a relatively new library called Upshot (formerly previewed as RIA/JS). Together they support presentation and editing of data across a set of pages that interact with local and remote data. They illustrate one prescriptive pattern of using distinct libraries together. You could also use them independently or replace one or more of them. For example, Upshot could be used with JsViews or jQuery UI or ISV controls and jQuery could be replaced with XUI. Some of the replacements may require some adaptation via a small library.

DataController on the Server

On the server-side, a new class called DataController which derives from ApiController, provides support for insert, update and delete operations in a unit of work with transaction support and automatic validations. It also provides a way to get the total count for paging along with the first page. It also provides a foundation for DAL-specific implementation of the above features. For example, DbController is a DataController that implements the above for Entity Framework Code First style of data access.

Single Page Application MVC Project Template

A new MVC project template for Single Page Application provides an educational tool and a way to start quickly. It includes scaffolding to generate a skeletal app that includes a DataController, optionally an Entity Framework DbContext and the scripts for basic query and edit tasks (CRUD operations). The template also includes a sample model class that you could use as is or replace with your favorite one to get started.

Can find more details from : http://www.asp.net/single-page-application/an-introduction-to-spa/overview/landingpage

Monday, February 6, 2012

Video and Audio with HTML 5

Yesterday i tried Video and Audio tags in HTML 5 , sharing some quick notes.
How It Works
To show a video in HTML5, this is all you need:


The control attribute adds video controls, like play, pause, and volume.
Video Formats and Browser Support

Browser
MP4
WebM
Ogg
Internet Explorer 9
YES
NO
NO
Firefox 4.0
NO
YES
YES
Google Chrome 6
YES
YES
YES
Apple Safari 5
YES
NO
NO
Opera 10.6
NO
YES
YES

MP4 = MPEG 4 files with H264 video codec and AAC audio codec
WebM = WebM files with VP8 video codec and Vorbis audio codec
Ogg = Ogg files with Theora video codec and Vorbis audio codec


To play an audio file in HTML5, this is all you need:




Audio Formats and Browser Support
Currently, there are 3 supported file formats for the

Browser
MP3
Wav
Ogg
Internet Explorer 9
YES
NO
NO
Firefox 4.0
NO
YES
YES
Google Chrome 6
YES
YES
YES
Apple Safari 5
YES
YES
NO
Opera 10.6
NO
YES
YES