Posts

Showing posts from 2010

ASP.NET 4.0 Feature - ClientIDMode Property

Let us see the new feature in ASP.NET 4.0 known as “ClientIDMode Property”. In the past we have seen that client id for any controls begin with “ctl00” and it always used to be a long names for eg: “gvBooks_ctl01_lnkOrderBook” . These id’s were very much needed when we used to while writing validations in javascript. Now in ASP.NET 4.0 we have the ClientIDMode Property which supports four different options as follows 1. AutoID – This is nothing but same as what we had prior to .NET 4.0 2. Predictable – This means that it concatenates the control name with the container (may be a contentplaceholder) for eg: contentplacholder1_btnSave 3. Static - This means that whatever the ID is set for the controls it uses that itself. 4. Inherit – This means that it will inherit the ClientIDMode property setting of the parent control. This is used in the different ways as seen below 1. It can be set in the web.config as <pages clientIDMode="Static"/> 2. It can be set at the control

Microsoft PDC 28th Oct - 29th Oct 2010

Microsoft PDC begins on 28th Oct. Check out for the more details http://player.microsoftpdc.com/ Cheers!!!

ASP.NET 4.0 Feature - Cleaner Markup in ASP.NET 4.0

Let us see the new feature in ASP.NET 4.0 known as the Cleaner Markup in ASP.NET 4.0 . We have a property “controlRenderingCompatbilityVersion” in the web.config which lets you decide if you want a cleaner markup. This is defaulted to “4.0” as of in ASP.NET. When we are migrating from older version this is always helpful in keeping the markups, which can be achieved by setting to 3.5 as seen below <pages controlRenderingCompatibilityVersion ="3.5"/> Hope this was cool feature. Please add your comments or suggestions. Cheers!!!

ASP.NET 4.0 Feature - Response.RedirectToRoute and Response.RedirectToRoutePermanent methods

Let us see the new feature in ASP.NET 4.0 known as the “Response.RedirectToRoute” and “Response.RedirectToRoutePermanent” methods. These helps to redirect to a specified url temporary or on permanent basis using the URL Routing mechanism. The Syntax is as follows Response.RedirectToRoute("View Titles by Author", new { TitleAuID = "172-32-1176" }); Response.RedirectToRoutePermanent("View Titles by Author", new { TitleAuID = "172-32-1176" }); Hope this was cool feature. Please add your comments or suggestions. Cheers!!!

ASP.NET 4.0 Feature - Response.RedirectPermanent() Method

Let us see the new feature in ASP.NET 4.0 known as the “Response.RedirectPermanent”. We have seen in the past where we use the “Response.Redirect” method to redirect to the requested Url to specified Url, this uses the HTTP 302 status code which is temporary redirect. This leads to a round trip from requested Url to specified Url when the user hits the requested Url. Now we have the “Response.RedirectPermanent” which uses the HTTP 301 status code which is a permanent redirect. This enables the search engines to store all the permanent redirects and index it which enables in searching it faster. The Syntax is Response.RedirectPermanent(“NewTitles.aspx”); Hope this was cool feature. Please add your comments or suggestions. Cheers!!!

IE 9 Beta

IE 9 beta is available for download at http://www.beautyoftheweb.com/

ASP.NET 4.0 Feature - MetaKeywords and MetaDescription Properties

Image
Let us see the new feature in ASP.NET 4.0 know as the “MetaKeywords and MetaDescription Properties”. These are new runtime properties added for search engine optimization. Which otherwise means that it will help for search engines searching for relevant pages. We can use the same as seen below in the code behind file in the page_load The other way to implement this is in the page directive section on the aspx page as seen below Hope this was cool feature. Please add your comments or suggestions. Cheers!!!

ASP.NET 4.0 Feature - URL Routing

Image
Let’s see the new feature in ASP.NET 4.0 known as “URL Routing”. URL Routing is a feature which is driven by the ASP.NET URL routing engine which enables the application to route to custom urls instead of actual urls which may have some querystrings etc. In the past we have seen urls like http://localhost/NewStore/Titles.aspx can be now show as http://localhost/NewStore/AllTitles or http://localhost/NewStore/Titles.aspx?ID=2 can be now shown as http://localhost/NewStore/Products/Fiction . Doesn’t this look great? Now let’s see how do we achieve this. We would be using the “System.Web.Routing” class which products us a method “MapPageRoute” which helps to do the routing. Let us see a simple example where we would have two pages one which shows All the Titles and another which shows Title for a specific Author Id. For this example I am using the Pubs Database. We would have to first create the two new Pages “Titles.aspx” and “TitlesbyAuthor.aspx” . Now the “Titles.aspx” shows All the Tit

ASP.NET 4.0 Feature - Clean Web.Config

Image
Lets see the feature in ASP.NET 4.0 which is known as “Clean Web.config” . If we have noticed the web.config in the previous version ASP.NET 3.5 it would be about 125lines . In ASP.NET 4.0 you would be surprised to see as shown below The only information that is available is enabling debugging . Wow.. Don’t you feel we have a clean web.config !!!! Hope this was cool feature. Please add your comments or suggestions. Cheers!!!

C# 4.0 Feature - CoVariance and ContraVariance

Lets see the new feature in C# 4.0 “CoVariance and ContraVariance". This is a very tricky concept and there are many illustrations in the web. If we had to do the following prior to C# 4.0 class Drivers { } class LaptopDriver : Drivers { } class DesktopDriver : Drivers { } class LanDriver : LaptopDriver { } delegate T GetDriver (); static void Main(string[] args) { GetDriver getLaptopDriver = () => new LaptopDriver(); GetDriver getDrivers = getLaptopDriver; Console.ReadLine(); } We would have got a error as follows Cannot implicitly convert type 'ConsoleApplication2.Program.GetDriver ' to 'ConsoleApplication2.Program.GetDriver ' To overcome this in C# 4.0 we have CoVariance which is mainly used for assignment compatability. We need to modify the code by adding a “out” keyoword in the delagate declaration as seen below class Drivers {

C# 4.0 Feature - Dynamic Keyword

Lets look into new C# 4.0 feature, “Dynamic” keyword. In the past we always used to type cast objects to a particular object or datatype if the available value is of another type. For eg: We have created a Employee Class public class Employee { public int EmployeeID { get; set; } public string EmployeeName { get; set; } } Now we have a InitilaizeEmployees() method, which has a written type as object public object InitializeEmployee() { Employee emp = new Employee(); emp.EmployeeID = 1; emp.EmployeeName = "Jack"; return emp; } Now if we had to assign the object “obj” to a employee object we had to type cast with “Employee” for eg: If we write Employee emp = InitializeEmployee(); We will get a compile type error, since it is not of the same type hence we will have to write as Employee emp =(Employee) InitializeEmployee(); To ease this we have a new keyword known as “Dynamic

C# 4.0 Feature - Named Arguments

Let’s discuss about the new feature in C# 4.0 “Named Arguments”. As seen in the last post regarding “Optional Arguments”, we would have wondered for the “Add” method we had three parameters. But If we wanted to pass the first and third parameters instead of second , Is this possible ? Lets see the code below private int Add(int i, int j = 1, int k = 0) { return i + j + k; } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(Add(2, 3).ToString()); } This will look like we are passing for value “i” and “j” and not “k”. So how can we achieve this ? In C#4.0 we have a new feature called “Named Arguments” where we can pass arguments with the parameter name : . The above code would be rewritten as follows private void button1_Click(object sender, EventArgs e) { MessageBox.Show(Add(2,k:3).ToString()); } Hope this was cool feature. Please add your comments or suggestions. Cheers!!!

C# 4.0 Feature - Optional Arguments

The feature that we are discussing today is called as “Optional Arguments”. Prior to C#4.0, whenever we need to pass optional parameters for a method, we used to use method overloading . For eg: private int Add(int i) { return i + 2; } Now if the Add method wanted to accept two parameters then we used to write as follows private int Add(int i, int j) { return i + j; } Now if the Add method wanted to accept two parameters then we used to write as follows private int Add(int i, int j, int k) { return i + j + k; } Eventually we had to write three overloaded methods based on the number of parameters passed and invoke the method based on the parameters passed. In C#4.0, we can rewrite the code by declaring parameters as optional as follows private int Add(int i, int j = 1, int k = 0) { return i + j + k; } When invoking this method and need only one parameter to be passed use it as

Back to Blogging ........

I have been missing from blogging for sometime since April. I am mostly on twitter @shaju or on facebook @ shajuthomas . But I intend to come back to blogging which i started way back in 2003. I was quite busy with my daily work schedules, but i know thats not a good reason from staying away. Hope to gain the momentum back again. See you all........ Happy Weekend.... God Bless you all....... Cheers!!!

Visual Studio & .NET 4.0 Released

Visual Studio & .NET 4.0 has been Released. T o know more read Scott Hanselman blog.   Cheers!!!     The information contained in this e-mail message may be privileged and/or confidential and protected from disclosure under applicable law. It is intended only for the individual to whom or entity to which it is addressed as shown at the beginning of the message. If the reader of this message is not the intended recipient, or if the employee or agent responsible for delivering the message is not an employee or agent of the intended recipient, you are hereby notified that any review, dissemination, distribution, use, or copying of this message is strictly prohibited. If you have received this message in error, please notify us immediately by return e-mail and permanently delete this message and your reply to the extent it includes this message. Any views or opinions presented in this message or attachments are those of the author and do not necessarily represent those of

Tips : WCF Service not working on IIS 7.0

I was hosting my WCF services built on .NET 4.0 in IIS 7. It failed with the error   System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.   I tried the aspnet_regiis –iru and Bingo it worked.   Hope this helps someone.   Cheers!!!

New look for www.asp.net

There is a new look for http://www.asp.net/ . Check out..   Cheers!!!

ASP.NET MVC 2 is released

I just happened to see this on Scott Hanselman’s blog that ASP.NET MVC 2 is released . It can be downloaded from http://www.microsoft.com/downloads/details.aspx?FamilyID=c9ba1fe1-3ba8-439a-9e21-def90a8615a9&displaylang=en   Cheers!!!

URL Routing in ASP.NET 4.0

URL Routing in ASP.NET 4.0 is a excellent which helps in SEO . For more info please read @ http://www.4guysfromrolla.com/articles/012710-1.aspx    

Response.RedirectPermanent in ASP.NET 4.0

Response.RedirectPermanent is a way to redirect using HTTP 301 (permanently) response.   For more Info Check : http://weblogs.asp.net/scottgu/archive/2010/01/05/asp-net-4-seo-improvements-vs-2010-and-net-4-0-series.aspx  

Apple IPad

Check about more on the new Apple IPad at   http://www.engadget.com/2010/01/27/the-apple-ipad/   http://www.engadget.com/2010/01/27/apple-ipad-event-video-now-online/      

Wish you all a Joyous and Prosperous Happy New Year 2010

The past year may be filled with lows and high, but remember all things happens for good. Hope the new year brings in all the best of things and take you to the next level.   Hope you all have a Christ Centred,  Joyous and Prosperous Happy New Year 2010.   Cheers