Items By Type: Snippet

Displaying Search Results In A WebGrid

Saturday, August 27, 2011 4:57 PM

jQuery ASP.NET Web Pages WebMatrix Razor WebGrid

A number of people have run into problems when trying to combine a search or filter form, and a WebGrid. The main issue that arises is when paging or sorting the search result or a filtered subset of it. Here, I look at the cause of the problem and what you can do about it.

Click to read more about Displaying Search Results In A WebGrid ...

Viewed 45364 times

11 Comments for this item

How To Maintain Scroll Position When Paging Or Sorting A WebGrid

Tuesday, August 23, 2011 9:13 PM

jQuery ASP.NET Web Pages WebMatrix Razor WebGrid

This snippet is one in a series showing how to use jQuery to enhance the behaviour of a Web Pages WebGrid. This example shows how to maintain scroll position on the page when paging or sorting the WebGrid.

Click to read more about How To Maintain Scroll Position When Paging Or Sorting A WebGrid ...

Viewed 21528 times

3 Comments for this item

How To Make A WebGrid Row Clickable

Tuesday, August 23, 2011 11:23 AM

jQuery ASP.NET Web Pages WebMatrix Razor WebGrid

This snippet is one in a series showing how to use jQuery to enhance the behaviour of a Web Pages WebGrid. This example shows how to make an entire row clickable so that the user is taken to another page that displays details of the selected row.

Click to read more about How To Make A WebGrid Row Clickable ...

Viewed 67012 times

7 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 11056 times

2 Comments for this item

Finding Yesterday in SQL and C#

Monday, July 12, 2010 9:27 PM

C# SQL

Here's something that comes up often in forums - How To Find Yesterday in SQL or C#. Piece of cake, if you know how, but tricky if you don't. And especially tricky to get the right value if you are not clear on the requirement.

Click to read more about Finding Yesterday in SQL and C# ...

Viewed 16751 times

4 Comments for this item

Named Anchors And MVC Urls

Monday, June 14, 2010 10:15 AM

ASP.NET MVC

Named Anchors are used to generate links to specific locations within a web document. Unless you are careful, you may end up having a little trouble getting these to work using the MVC LinkExtension helpers.

Click to read more about Named Anchors And MVC Urls ...

Viewed 19027 times

0 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 11709 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 40209 times

7 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 29825 times

15 Comments for this item

Referencing CheckBoxes in GridView, Repeater and DataList controls

Thursday, August 30, 2007 10:29 AM

ASP.NET 2.0 ASP.NET Web Forms

If you want to find which CheckBoxes were selected in a multiple record DataBound control, the way that you you do it depends on the type of control you use. These examples demonstrate a CheckBox control being added to a GridView, Repeater and a DataList. For simplicity, I have placed all three controls on the same page, and used the Access version of theNorthwind database. One AccessDataSource control is used to bind the results of "SELECT [CategoryID], [Description], [CategoryName] FROM [Categories]" to all three controls.

Click to read more about Referencing CheckBoxes in GridView, Repeater and DataList controls ...

Viewed 69668 times

6 Comments for this item

List the contents of a folder and link to each file

Friday, August 10, 2007 9:33 PM

ASP.NET 2.0

Iterating the contents of a folder is straightforward using classes from System.IO, and listing them as links to the actual file just requires a bit of html added to each file name.

Click to read more about List the contents of a folder and link to each file ...

Viewed 19184 times

2 Comments for this item

Exporting data to a CSV, tab delimited or other text format

Thursday, August 2, 2007 11:41 PM

ASP.NET 2.0 ADO.NET

A question that often comes up in forums is how to export data to a CSV file, or other text format. Here's a method that takes data from a DataReader and writes it to a file.

Click to read more about Exporting data to a CSV, tab delimited or other text format ...

Viewed 41322 times

4 Comments for this item

A more efficient RSS feed with C#

Wednesday, June 6, 2007 11:15 PM

C# ASP.NET 2.0

The contents of an RSS feed only change when items that appear in it are added or amended, so the feed created in the previous article (Create an RSS Feed In ASP.NET 2.0 C#) is rather inefficient, in that the output is generated everytime the feed is requested. Here's an improvement.

Click to read more about A more efficient RSS feed with C# ...

Viewed 14064 times

0 Comments for this item

Basic file management with System.IO in ASP.NET

Tuesday, May 29, 2007 12:37 PM

C# ASP.NET 2.0

Some basic file and folder management tasks that require the use of classes inside System.IO

Click to read more about Basic file management with System.IO in ASP.NET ...

Viewed 18279 times

0 Comments for this item

How to read a remote web page with ASP.NET 2.0

Monday, May 21, 2007 9:38 PM

C# ASP.NET 2.0

Two classes in the System.Net namespace make it very easy to obtain the html of a remote web page. These are the HttpWebRequest and HttpWebResponse. Here's a quick demo.

Click to read more about How to read a remote web page with ASP.NET 2.0 ...

Viewed 102331 times

8 Comments for this item

Recent Comments

Vijay 5/25/2015 2:12 PM
In response to How To Send Email In ASP.NET MVC
Thanks...

RR 5/25/2015 8:58 AM
In response to Web Pages - Efficient Paging Without The WebGrid
@MIke.. is it possible to combine pagination and filter (change category ) in the script? Thanks...

Irfan Khan 5/25/2015 6:19 AM
In response to Highlighting Keywords Found In Search Results
This is truely helpful. Thank you for the brilliant tip....

Manoj Kulkarni 5/25/2015 4:46 AM
In response to Custom TagHelpers in ASP.NET MVC 6
Thank you for nice article. Really helpful....

Sean 5/21/2015 4:20 AM
In response to ASP.NET MVC 5 with EF 6 - Working With Files
Thank you for the tutorial. Saving to the database works, but the save FilePath is not working. It...

KrASh 5/19/2015 11:10 PM
In response to Adding Search
Hello Mike, I have a question about the second search. In one line it has a where with the title and...

KrASh 5/19/2015 11:04 PM
In response to Accessing Your Model's Data from a Controller
Thanks, I had some silly mistake, can't remember now what it was (had some personal problems last i...

Satyabrata Mohapatra 5/18/2015 4:29 PM
In response to Error Handling in ASP.NET Razor Web Pages
Great article. Learned a lot....

Corstian Boerman 5/13/2015 12:59 PM
In response to ASP.NET 5 Middleware, Or Where Has My HttpModule Gone?
It looks as if this technique doesn't work anymore. (As of the VS 2015 RC release) When adding it...

Alvin 5/12/2015 1:20 PM
In response to Razor Web Pages E-Commerce - Adding A Shopping Cart To The Bakery Template Site
Maybe ability to update quantity of the items once you are in the "Review Cart" step. Also, if on...