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 version of Jquery and JQuery UI. This Script manager enable cdn property will fetch all the script from that CDN Automatically. Developer don'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 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.
<form id="form1" runat="server">
<asp:ScriptManager ID="cdnScriptManager" EnableCdn="true" runat="server">
<asp:UpdatePanel ID="cdnUpdatePanel" runat="server">
<asp:TextBox ID="txtHelloWorld" runat="server"></asp:TextBox>
<asp:AsyncPostBackTrigger ControlID="btnHelloWorld" EventName="Click" />
<asp:Button ID="btnHelloWorld" runat="server" onclick="btnHelloWorld_Click" Text="Hello World!!"/>
Now I am going to create a click event which will change textbox text’. Following is a code for that.
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.
Now Let’s see its view source and see how it’s look like. Following is a screenshot of view source.