Home / ASP.NET Weblogs

January 2009 - Posts

Posted to:

T4 Templates in ASP.NET MVC

Here’s a little known fact about T4 Templates…well besides that they exist in the first place. Visual Studio 2005 had support for T3 templates. T4 is the natural successor to T3. T3 is also the abbreviation used when marketing the movie Terminator 3: Rise of the Machines . I heard that the names are related, but I haven’t confirmed it beyond a doubt, which seems appropriate given the title of the movie. But you didn’t hear that from me, deal? Dude looks ready to write some code! Although they’ve been around forever, I haven’t really dived into T4 templates until recently as I’ve been using them in Subtext. I’m excited that we’re now incorporating them into ASP.NET MVC . The Visual Web Developer Team Blog just posted an in-depth look at T4 templates...
Posted to:

ASP.NET MVC RC Refresh

Hello there. :) On Tuesday, we announced the release candidate for ASP.NET MVC . While there is much new in there to be excited about and many many bug fixes, there were two changes introduced in the RC that broke some scenarios which previously worked in the Beta, as reported by customers. We’ve updated the Release Candidate with a refresh that addresses these two issues. You can use the recently released Microsoft Web Platform Installer 1.0 to install ASP.NET MVC RC Refresh. It happens to be a handy tool for installing not just ASP.NET MVC, but everything you might need to use ASP.NET MVC such as Visual Web Developer Express 2008 SP1. The link on the official download page appears to be updated with the new MSI (we pushed it out yesterday...
Posted to:

Delete Link With Downlevel Support

Earlier this morning, I posted on making a simple jQuery delete link which makes it easy to create a delete link that does a form post to a delete action. Commenters pointed out that my solution won’t work for down-level browsers such as some mobile phones, and they were right. I wasn’t really concerned about down-level browsers. One solution for down-level browsers is to render a proper form with a submit button, and then hide the form with JavaScript. Of course this takes a bit more work. Here’s what I did. I made sure I had the following script in my master template. < script type ="text/javascript" > $( "form.delete-link" ).css( "display" , "none" ); $( "a.delete-link" ).show(); $(...
Posted to:

ASP.NET MVC 1.0 Release Candidate now available in Web Platform Installer

ASP.NET MVC 1.0 RC can now be installed with Web Platform Installer: http://www.microsoft.com/web/channel/products/WebPlatformInstaller.aspx Here is a quick description of Web Platform Installer from the Web Platform Installer website: “The Web Platform Installer (Web PI) is a simple tool that installs Microsoft's entire Web Platform, including IIS, Visual Web Developer 2008 Express Edition, SQL Server 2008 Express Edition and the .NET Framework. Using the Web Platform Installer’s user interface, you can choose to install either specific products or the entire Microsoft Web Platform onto your computer. The Web PI also helps keep your products up to date by always offering the latest additions to the Web Platform.“ I tried it out and was...
Posted to:

Simple jQuery Delete Link For ASP.NET MVC

In a recent post, Stephen Walther pointed out the dangers of using a link to delete data . Go read it as it provides very good coverage of the issues. The problem is not restricted to delete operations. Any time you allow a GET request to modify data, you’re asking for trouble . Read this story about something that happened to BackPack way back in the day to see what I mean. The reason that delete operations deserve special attention is that it’s the most common case where you would use a link to change information. If you were editing a product record, for example, you would use a form. But a delete operation typically only needs one piece of information (the id) which is easy to encode in the URL of a GET request. If you are using jQuery,...
Posted to:

Alternating styles in DataView

A few months ago, I showed how you can alternate styles using CSS in a server-side ListView , by selecting the class depending on the remainder of the division of the data index by two. Well, you can do the exact same thing with the client-side DataView. Let’s first define the classes we’ll want to apply to the even and odd rows: tbody tr { background-color : #f0f0f0 ; } tbody tr.odd { background-color : #c0c0c0 ; } Then, we can use the class namespace to bind the presence of a CSS class to a Boolean condition: < tr class : odd ="{{ $index % 2 }}"> Within the context of the template, $index is the index of the current data item, so $index % 2 will be evaluated as 1 and 0 alternatively. For JavaScript, when evaluated in a Boolean...
Posted to:

T4 Templates: A Quick-Start Guide for ASP.NET MVC Developers

As mentioned in our recent blog post on the ASP.NET MVC Release Candidate , our code-generation features (namely, Add Controller and Add View) now use the T4 (Text Template Transformation Toolkit) templating technology behind the scenes. Because users can customize the templates to a great extent, we wanted to make a post to bring everyone up to speed on T4. Template Locations and Template Override The Add Controller and Add View dialogs both perform code generation that use T4 templates behind the scenes. These templates can be modified to customize the generated code from these tools. You can find the templates at the following location: [Visual Studio Install Directory]\Common7\IDE\ItemTemplates\[CSharp | VisualBasic]\Web\MVC\CodeTemplates...
Posted to:

Feed Visual Studio and Visual Web Developer with the www.ASP.net web site !

The VS / VWD startup page displays a collection of current items of interest to developers. But did you know that you can configure what gets displayed in your Visual Studio / Visual Web Developer home page. The default looks like this. But see here how I've changed it to show the list of new articles from the www.asp.net web site !!!! Now when I fire up Visual Web developer I get all the latest articles from the ASP.NET web site articles list. In a few days I'll have a NEW RSS feed that aggregates all the "What's new" stuff from the ASP.NET web site. I think it's a cool option that helps keep me "up to date" ! Read More...
Posted to:

RTFLF - Read the Expletive Log File

A buddy of mine and I had a nice slap in the face yesterday. I was helping him deploy an ADO.NET Data Service to a large company's staging server  and we were seeing REALLY odd behavior. We'd request something like /myservice.svc and get a 404. But we could request /myservice.svc/Stuff or /myservice.svc/?metadata. We settled in to debug this. We thought we were "getting down to basics." You know, you've done this. The conversation goes something like: "Ok, people, what's the definition of insanity? Trying the same thing and expecting a different result." "Right...let's challenge all our assumptions. Let's start from scratch. Can get Hello World working?" "What's the ACLs on...
Posted to:
by: 
01-29-2009, 10:49 AM

ASP.NET 4.0: Page.Keywords and Page.Description simple, but useful!

One of the smaller additions we’ve made to ASP.NET 4.0 WebForms is the addition of two properties on the Page class, Page.Keywords and Page.Description. What these two properties do is provide access to / create meta tags within your page as follows: < head runat ="server"> < title > Untitled Page </ title > < meta name ="keywords" content ="These, are, my, keywords' /> < meta name ="description" content ="This is the description of my page" /> </ head > Simple, right? In fact these two properties work the same way as Page.Title works: 1. If there are no meta tags in the head element matching the property names e.g., name=”keywords” for Page.Keywords and name...

1 2 3 4 5 Next > ... Last »

Archives