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 48209 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 22284 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 70109 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 11450 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 17133 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 19704 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 12177 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 41793 times

8 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 31099 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 71216 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 20112 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 43786 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 14240 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 18564 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 105304 times

8 Comments for this item

Recent Comments

sandeep 8/28/2015 7:03 AM
In response to 7 C# 6.0 Features That Every ASP.NET Developer Should Know About
very good article, i like it........keep writing such quality article in future. thx Mike....

Hassan, MVC Learner 8/28/2015 6:37 AM
In response to Get The Drop On ASP.NET MVC DropDownLists
Great Help, simple, great and patiently explained article !...

Anvesh 8/28/2015 12:39 AM
In response to ASP.NET MVC DropDownLists - Multiple Selection and Enum Support
what if we are taking postback values from FormCollections instead of an array int[] category. How...

Ben 8/27/2015 10:50 PM
In response to Simple File Download Protection with ASP.NET
Is it possible to setup your project to publish files to outside of your root directory? I would to...

Fred 8/26/2015 12:50 AM
In response to WebMatrix Opens Wrong Version Of Visual Studio
I enjoyed many of your tutorials but the problem is none of the tutorials are combined like most be....

Muhammad Ashikuzzaman 8/25/2015 2:48 PM
In response to Managing Checkboxes And Radios In ASP.NET Razor Web Pages
That's a very good tips for razor...

Sergey 8/25/2015 8:32 AM
In response to More Flexible Routing For ASP.NET Web Pages
Hi. How I can set up my site to get urldata from link for default page? site.com/default/1-...

Tony Gray 8/25/2015 6:27 AM
In response to Adding Validation
Hi Mike, Really helpful article and series. Thanks. Small typo in 4th paragraph you have so...

amanda n 8/25/2015 12:38 AM
In response to Solving the Operation Must Use An Updateable Query error
Thank you very much. I'm a uni student and while solving coding problems is usually enjoyable and me...

salman 8/23/2015 9:25 AM
In response to How To Send Email In ASP.NET MVC
thanks ......