How to Enable CDN Property for ScriptManager in ASP.NET-Part 1

No.of Views829
Bookmarked0 times
Downloads 
Votes0
By  jalpesh   On  20 Dec 2010 07:12:04
Tag : ASP.NET , ASP.NET 4.0 Forms
ASP.NET 4.0 has been a great step forward to the programming. Microsoft has done incredible job with the performance. One of them is Enable CDN Property in asp.net 4.0 Script Manager
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

ASP.NET 4.0 has been a great step forward to the programming. Microsoft has done incredible job with the performance. One of them is Enable CDN Property in asp.net 4.0 Script Manager.

Let's explore it in details. As you all know that Microsoft is Providing Content Delivery Network for all the Ajax script that is used by Microsoft Ajax and All versions of JQuery and JQuery UI. This Script manager enable CDN property will fetch all the script from that CDN Automatically. Developer doesn’t have to worry about. As you know new generation browsers are like IE8 and Firefox are creating a new thread of each JS or CSS include in Webpage if they are coming from the CDN(Content Delivery Network).

So this will be a great measure step towards it. Let's take an example to explore the things. I am taking one simple example which will demonstrate use of this. I am tasking a Textbox and Button. On the button click event it will update textbox's text property. I am going to use update panel to use Microsoft Ajax. For that first I need a script manager so I have taken script manager and I have set its property EnalbleCdn=true. So without posting back whole it post back only that portion which are required.

I have putted textbox in content template of update panel and I have created asynchronous post back trigger for button click event. So it will update the textbox text without creating post back. Let's how I have created. Following are Simple HTML for that.

Html Code
 

<body>
   <form id="form1" runat="server">
   <div>
       
       <asp:ScriptManager ID="cdnScriptManager" EnableCdn="true" runat="server">
       </asp:ScriptManager>  
       
       <asp:UpdatePanel ID="cdnUpdatePanel" runat="server">
           <ContentTemplate>
                 <asp:TextBox ID="txtHelloWorld" runat="server"></asp:TextBox>
           </ContentTemplate>
           <Triggers>
                 <asp:AsyncPostBackTrigger ControlID="btnHelloWorld" EventName="Click" />
           </Triggers>
       </asp:UpdatePanel>
        
 
       <asp:Button ID="btnHelloWorld" runat="server" onclick="btnHelloWorld_Click"  Text="Hello World!!"/>
       
   </div>
   </form>
</body>


Now I am going to create a click event which will change textbox text’. Following is a code for that.

C# Code

protected void btnHelloWorld_Click(object sender, EventArgs e)
{
    txtHelloWorld.Text = "Hello World";
}

That’s it Let’s run that with Ctrl+ F5 and It will look in firefox browser like following.

Image Loading

Now Let’s see its view source and see how it’s look like. Following is a screenshot of view source.

Image Loading

As you can see its fetching all the JS from Microsoft Ajax Content delivery network. Isn’t that great. You just to have enable CDN Property =true and It will do rest of Job. That’s power of asp.net 4.0. Hope you liked it. Stay tuned for more in Part 2.

 
Sign Up to vote for this article
 
About Author
 
jalpesh
Occupation-Software Engineer
Company-DotNetJaps
Member Type-Expert
Location-India
Joined date-08 May 2010
Home Page-http://www.dotnetjalps.com
Blog Page-http://www.dotnetjalps.com
I am jalpesh vadgamaa an Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having experience of five year in Microsoft .NET Technology.I am working as Project Leader in Mid Size company.My work area comprises of Enterprise Level projects using ASP.NET and other Microsoft .NET Technologies.Please feel free to contact me for any queries via posting comments on my blog I will try to reply as early as possible.
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top