How to set Html.RadioButtonFor as selected by default in MVC3

The below is the code snippet of how to use the Html helper for Radio Button in MVC.

<td> Will Accept?</td>


@Html.RadioButtonFor(x => x.WillAccept, true)

@Html.RadioButtonFor(x => x.WillAccept, false)



Now how can we show one radio button selected by default? There are two ways of doing it.

The first option is to pass the “checked” html attribute as a parameter to the Html helper method by creating an anonymous object as below

<td> Will Accept?</td>


@Html.RadioButtonFor(x => x.WillAccept, true, new { @checked = “checked” })

@Html.RadioButtonFor(x => x.WillAccept, false)


The Second option is to set the value of the corresponding model property in the controller itself

public ActionResult Feedback()


UserResponse usr= new UserResponse();

usr.WillAccept = false;

return View(“Feedback”,usr);


Both work perfectly, but note that, setting the value via model overrides passing via html parameter. So if both of the above options are used the default value of the radio button will be false.

Leave a reply if you find it useful


Cheap TFS hosting

Discount offers limited time offer of 30days free TFS 2010 hosting and 20$/month. Looks reasonable offering. Details in the below link vs LAMP – Case of Digg and StackOverflow Sites

ScottGu retweeted an interesting post today about Digg and StackOverflow

Nice RT @spolsky Digg: 200MM page views, 500 servers. Stack Overflow: 60MM page views, 5 servers. What am I missing?

then goes on to retweet the reason too

RT @spolsky (nb Stack Overflow is ASP.NET MVC + SQL Server, Digg was LAMP)

now that is very bold to claim isnt it..? Is PHP on Linux that bad in terms of performance..? I did some search and it seems the claim might be indeed valid at least as per the below link

I will try to post some MVC related stuff in coming weeks.

History of C# – Past present and future

Here is a nice summary of the past present and future of C# I captured from a  nice blog

  • C#1 was all about delivering a new language for a new platform.
  • C#2 was all about providing generics to improve strong typing, especially in collection handling situations.
  • C#3 was all about letting write strongly typed queries abstracted from the date source. As a consequence C#3 fosters a more declarative way of programming.
  • C#4 was mainly about dynamic programming to inter-operate with dynamic programming environment.
  • C#5 will be concerned with meta-programming.

.net posts vs Sharepoint posts

Lately, my posts to this blog have been mostly on Sharepoint. Though thats not the intention of creating this site, somehow my posts have been more biased towards Sharepoint. I have to admit that since I started posting on Sharepoint this blog’s hit rate has skyrocketed. Though thats encouraging, its not the vision with which I created this blog. I am planning to give Sharepoint posts some rest and start posting on general .net technologies covering clr to c# and wpf to

SharePoint 2010 Development Environment on Windows 7

With Sharepoint 2010 being available since yesterday for General Availability, I thought I will set up the dev environment in my laptop. I have Windows 7 ultimate (64 bit) in my laptop (Vista should also suffice) with 4 gig memory and that should be a reasonable configuration to install Sharepoint 2010.

I downloaded the 180 days trial from here. I choose the “SharePoint Server 2010 Enterprise Client Access License features” as I felt that it better suits my development needs. The install steps are clearly captured here. The install is easy if you follow the exact steps mentioned in the page. Except that, in the Step 2 replace the following commands

For SharePoint Server 2010:
c:\SharePointFiles\OfficeServer /extract:c:\SharePointFiles


For SharePoint Server 2010:
c:\SharePointFiles\SharepointServer.exe /extract:c:\SharePointFiles

Otherwise you shouldnt be facing any issues with the setup. I havent yet started promgramming and testing out some code. What are your experiences..? Do let me know if you face any issue.

How to find Sharepoint 2007 Trial Expiry date?

So you have installed Sharepoint Trial edition which usually expires after 180 days. After some days you might wonder at what date exactly your installation expires. I had trouble finding it too and posted my question in technet sharepoint forum. Eventually found the answer and posted that too in the thread. Find it in below thread. I believe this applies to Sharepoint 2010 also.