6 items found in the Extension Method Category

HTML5 Form Helpers For WebMatrix

Thursday, September 20, 2012 2:56 PM

Extension Method ASP.NET Web Pages WebMatrix HTML5

It's an odd thing: WebMatrix 2 is lauded for its support of HTML5, but the Web Pages framework doesn't include any helpers for the new HTML5 form input types such as email or color. It's fair to say that support among browsers for the new inputs is patchy at the moment, but with barely a week flying past without a new version of one or other browser being released, it won't take long for that to change. So in the meantime, if you prefer to use helpers, you have to write your own for rendering HTML5 forms.

Click to read more about HTML5 Form Helpers For WebMatrix ...

Viewed 26575 times

5 Comments for this item

Why You Can't Use Extension Methods With A WebGrid

Thursday, January 27, 2011 12:58 PM

Extension Method ASP.NET Web Pages WebMatrix WebGrid

An interesting question came up recently on the ASP.NET forums. In it, the questioner was attempting to use my Chop() extension method to limit the number of characters in a WebGrid column but it wouldn't work. At first, I was a little stumped, so I tried it myself and got an error message:

Click to read more about Why You Can't Use Extension Methods With A WebGrid ...

Viewed 9390 times

2 Comments for this item

WebMatrix - Database Helpers for IN Clauses

Saturday, September 11, 2010 9:35 AM

Extension Method ASP.NET Web Pages WebMatrix Razor

There are times when you want to query a database for records matching a range of values, but you do not know what those values are, or even how many there are at design time. You could dynamically build your WHERE clause with multiple ORs, or you can use the SQL IN clause - except that the current database helpers in WebMatrix don't make this easy. It's about time that was fixed....

Click to read more about WebMatrix - Database Helpers for IN Clauses ...

Viewed 16759 times

8 Comments for this item

Converting URLs Into Links With Regex

Saturday, May 22, 2010 10:56 PM

C# Extension Method

Following on from the recent spate of extensions methods I've posted, here's another I use to convert URLs and email addresses into links within HTML. You may want to restrict users from submitting HTML tags via forms in your application, which means that URLs and email addresses that they submit appear as plain text unless they are subjected to some kind of processing.

Click to read more about Converting URLs Into Links With Regex ...

Viewed 10207 times

1 Comment for this item

Highlighting Keywords Found In Search Results

Saturday, May 22, 2010 7:41 PM

C# ASP.NET 3.5 Extension Method ASP.NET Web Forms

A common question in the forums is how to highlight key words found in search results. Here's an extension method that does that, both for partial matches, or whole word matches.

Click to read more about Highlighting Keywords Found In Search Results ...

Viewed 18659 times

4 Comments for this item

Displaying The First n Characters Of Text

Sunday, May 16, 2010 9:59 AM

C# ASP.NET 3.5 Extension Method

Displaying the first n characters of a block of text on a page without chopping words off halfway through is a common requirement. There are a number of ways to achieve this, but here's an extension method that you might find useful.

Click to read more about Displaying The First n Characters Of Text ...

Viewed 21451 times

13 Comments for this item