Tech Manthan

July 13, 2007

C# 3.0 New Features

Filed under: .Net Manthan — Himanshu Poddar @ 2:08 pm

What’s New in C# 3.0

By: Himanshu Poddar

Even though C# 3.0 is not even standardized yet, Microsoft provided a preview release at its Professional Developers Conference (PDC) in September so eager developers could try out some of the expected features. This article discusses the following major new enhancements expected in C# 3.0:

  1. Implicitly typed local variables
  2. Anonymous types
  3. Extension methods
  4. Object and collection initializers

(more…)

May 29, 2007

AJAX Implemetation

Filed under: .Net Manthan — sandipdavda @ 3:07 pm

AJAX(ASP.Net) Implemetation

By Priyank Rach

In previous article on Ajax http://techmanthan.wordpress.com/2007/05/07/ajax/, Himanshu had discussed about the Ajax web application model, how it differs from classic web application model, Advantages & disadvantages of Ajax. In this article we will see how to start with Ajax in ASP.Net.

First you will have to download ASP.Net Ajax Extension. It can be free download from web. Now go for its installation. After the successful installation of it, you will able to see a new template in wizard of creating a new web site. It would be named as “ASP.Net Ajax Enabled Website”.

template2.jpg

In this web site you will be able to see “Ajax Extensions” in toolbar. It has the controls like script manager, Update panel which gives Ajax benefits to your web application.

toolbar2.jpg

As you will be able to see there form is default loaded with script manager. It loads all necessary scripts for Ajax controls. Now you can drag the Update Panel. Update panel is the control which allows asynchronous post back to your application. Means you can refresh the controls inside the panel without refreshing the whole page.

Now as this indicate, controls within the update panel can refresh the portion covered by the panel. Similarly you can refresh the panel by control which is outside of that panel also. These can be gained using “Triggers”. In trigger also you can have the option to partially refresh the page or our convential refresh (whole page). Trigger can be fired on various events like Button click, dropdown selected index change or radio button state change etc.

This was related to creating a new Ajax enabled web site, but if you already have a web application and if you want to have Ajax features in it then you may need to create a dummy Ajax enabled application through template and copy the web.config file to your web application’s web.config file. You may need to copy only the Ajax related portion from your web.config file.

Let us know how useful you find this article…

May 1, 2007

Silverlight - Microsoft Changing the Web World Over Night?

Filed under: .Net Manthan — Himanshu Poddar @ 1:24 pm

Silverlight - Cross-Browser, Cross-Platform Plug-In

By: Himanshu Poddar 

Silverlight is a cross-browser, cross-platform plug-in for delivering the next generation of Microsoft .NET–based media experiences and rich interactive applications for the Web. Yes, Microsoft will make the Silverlight browser plug-in freely available for all supported platforms. AJAX, Visual Basic .NET, C#, Python, and Ruby and integrates with existing Web applications. Silverlight media capabilities include fast, cost-effective delivery of high-quality audio and video to all major browsers including Mozilla Firefox, Apple Safari, and Windows Internet Explorer running on Mac OS or Microsoft Windows. By using Microsoft Expression Studio and Microsoft Visual Studio, designers and developers can collaborate more effectively using the skills they have today to light up the Web of tomorrow. 

Key benefits of Silverlight include: 

1. Compelling cross-platform user experiences

Deliver media experiences and rich interactive applications (RIA) for the Web that incorporate video, animation, interactivity, and stunning user interfaces (UIs). Seamless, fast installation for users, thanks to a small, on-demand, easy-to-install plug-in that is under 2 megabyte (MB) in size and works with all leading browsers. Consistent experiences on Windows and on Mac OS without any additional installation requirements.   Create richer, more compelling Web experiences that take greater advantage of the client for increased performance. Stunning vector-based graphics, media, text, animation, and overlays enable seamless integration of graphics and effects into any existing Web application.  Enhance existing standards/AJAX-based applications with richer graphics and media and improve their performance and capabilities by using Silverlight. 

2. Flexible Programming Model with Collaboration Tools

Based on the Microsoft .NET Framework, Silverlight enables developers and designers to easily use existing skills and tools to deliver media experiences and RIAs for the Web. Choice of programming languages such as AJAX, Visual Basic .NET, C#, Python, and Ruby offers developers and designers the flexibility to use their existing skills without the need to learn a new language.   Simple integration with existing Web technologies and assets means Silverlight works with any back-end Web platform or technology. No “rip and replace” required. Silverlight integrates with your existing infrastructure and applications, including Apache and PHP, as well as with JavaScript and XHTML on the client.   Role-specific tools for both designers and developers that take advantage of Web standards and the breadth of the Microsoft .NET-connected software features. Designers will like that Expression Studio creates interactive UIs and media rich experiences, prepares media for encoding and distribution, and creates World Wide Web Consortium (W3C) standards-compliant sites by using modern XHTML, XML, XSLT, CSS, and Microsoft ASP.NET.

3. High-quality media, low-cost delivery

Unified media format scales from high definition (HD) to mobile with Windows Media Video (WMV), the Microsoft implementation of the Society of Motion Picture and Television Engineers (SMPTE) VC-1 video standard, as well as support for Windows Media Audio (WMA) and MP3 audio.   Add vector-based graphics and overlays to media with support for integration of graphics that scale to any size and broadcast-style overlays for tickers and closed captioning.  Flexible ad-insertion solutions with video and animation including the ability to deliver fluid, broadcast-style video or animated advertisements without any loss of visual fidelity or motion quality.  

4. Connected to data, servers, and services

Create mash-ups by incorporating data and services from anywhere on the Web by using Silverlight support for LINQ and LINQ-to-XML. Access data with common protocols like JSON, RSS, POX, and REST. Increase discoverability of RIA content that can be indexed and searched, thanks to the Silverlight text-based XAML format.   

Download Silverlight from: http://www.microsoft.com/silverlight/downloads.aspx

How to Use Embedded JavaScript Files in ASP.NET AJAX

Filed under: .Net Manthan — Himanshu Poddar @ 1:14 pm

How to Use Embedded JavaScript Files in ASP.NET AJAX

By: Himanshu Poddar 

It’s pretty easy to setup a .js file in your web project with some code in it. Sometimes though the code in said file is associated with say a custom client control (something that inherits from Sys.UI.Control) that is in its own assembly (not your web project). This is how our controls are setup for our platform.  The problem is now that we have code in js files, they have to be replicated across all our web projects and that’s just no fun.  So instead we moved to having the js files embedded in our main class library.  The server controls register these files and they are then pulled out of the assembly and sent down to the client and cached.   Here’s how to set this up yourself…Add the following line as the last line in your js file:if (Sys != undefined) Sys.Application.notifyScriptLoaded(); 

This tells ASP.NET AJAX that the file is done loading.  This is needed because all embedded js files stream down in the same “file” so the end of the file isn’t necessarily the end of what’s streamed down to the client.  Unlike when you just like to a js file regularly. Now, in Visual Studio go to the properties window while your js file is selected.  Change the Build Action to Embedded Resource.  This will compile the file into the assembly as a resource.  If you open up reflector and venture through, you’ll find the js file.  Now in your server control, add this line so ASP.NET knows about the resource (and what mime type to send it down as): [assembly: WebResource("EvNet.Web.Templates.Scripts.Toolbar.js", "text/javascript")] Now anytime you add a ScriptReference to a ScriptManager, your file will be streamed down to the client.  Just specify the resource name (This is the physical file path down to the file starting at the root of your class library with slashes replaced by periods) and the assembly the resource is in and you’re done.  No need to worry about where the file is anymore.   This of course works when implementing IScriptControl.GetScriptReferences in your server control too:

public IEnumerable<ScriptReference> GetScriptReferences()
{
     return new ScriptReference[]
{ new ScriptReference(”EvNet.Web.Templates.Scripts.Toolbar.js”, “EvNet”) };
}
 

Enjoy!

Blog at WordPress.com.