Wrox Programmer Forums
|
BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950
This is the forum to discuss the Wrox book ASP.NET MVC Website Programming Problem Design Solution by Nicholas Berardi, Al Katawazi, and Marco Bellinaso; ISBN: 9780470410950
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 13th, 2010, 10:14 AM
Authorized User
 
Join Date: Mar 2009
Posts: 68
Thanks: 6
Thanked 0 Times in 0 Posts
Default Title.ToUrlFormat()

What is this code trying to do, Not sure I understand, was the string class overloaded to include a method ToUrlFormat(), if so where is it.

Title.ToUrlFormat().

if title is the Url why not just

Path = UrlEncode(title)

I still think I'm missing something, can this be explained
 
Old April 13th, 2010, 10:17 AM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Posts: 102
Thanks: 1
Thanked 16 Times in 16 Posts
Send a message via AIM to nberardi
Default

ToUrlFormat() makes the slug for the URL.

So if you have the following title

"How is my title goin' to be formatted for everybody."

it would get changed to

how-is-my-title-goin-to-be-formatted-for-everbody

Nick
__________________
Check out my blog at: http://www.coderjournal.com
 
Old April 13th, 2010, 10:37 AM
Authorized User
 
Join Date: Mar 2009
Posts: 68
Thanks: 6
Thanked 0 Times in 0 Posts
Default Title.ToUrlFormat()

Still not sure where the code is to that, it looks like it looks for the Url path.

Path = title.ToUrlFormat();

title is a string and there is not a method for string that match ToUrlFormat()
 
Old April 13th, 2010, 11:04 AM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Posts: 102
Thanks: 1
Thanked 16 Times in 16 Posts
Send a message via AIM to nberardi
Default

Read up on extension methods.

http://msdn.microsoft.com/en-us/library/bb383977.aspx
__________________
Check out my blog at: http://www.coderjournal.com
 
Old April 13th, 2010, 11:10 AM
Authorized User
 
Join Date: Mar 2009
Posts: 68
Thanks: 6
Thanked 0 Times in 0 Posts
Default extension mathods

I found this, is this what you mean by extension methods

public static class StringExtensions
{
private static readonly Regex UrlReplacementExpression = new Regex(@"[^0-9a-z \-]*", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant);


/// <summary>
/// Toes the URL part.
/// </summary>
/// <param name="content">The content.</param>
/// <returns></returns>
public static string ToUrlFormat(this string content)
{
return UrlReplacementExpression.Replace(content.Trim(), String.Empty).Replace(' ', '-').ToLowerInvariant();
}
 
Old April 13th, 2010, 11:12 AM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Posts: 102
Thanks: 1
Thanked 16 Times in 16 Posts
Send a message via AIM to nberardi
Default

Try it out, and take a look at the link I sent you.
__________________
Check out my blog at: http://www.coderjournal.com
 
Old April 13th, 2010, 11:32 AM
Authorized User
 
Join Date: Mar 2009
Posts: 68
Thanks: 6
Thanked 0 Times in 0 Posts
Default The Link

OK I understand, what the link explains but I feels as if I'm still missing something, or maybe my problem was I was having trouble with the path in another program I was doing and was hoping this was my solution.

path = title.ToUrlFormat();

I read this as the title has the Url path in it, or is the Url path and that the ToUrlFormat is an extension method that will return that part of it, and if that is the case, what part of it was being done in the extension method.

this is great stuff and I appreciate all the help, I think I'm asking what others want to but not asking, or maybe this is just me. I hope I'm not being picky with this.
 
Old April 13th, 2010, 11:37 AM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Posts: 102
Thanks: 1
Thanked 16 Times in 16 Posts
Send a message via AIM to nberardi
Default

I don't understand your question.
__________________
Check out my blog at: http://www.coderjournal.com
 
Old April 13th, 2010, 11:51 AM
Authorized User
 
Join Date: Mar 2009
Posts: 68
Thanks: 6
Thanked 0 Times in 0 Posts
Default Question

I guess my question do you have source code where you have these extension methods that you use in the book?
 
Old April 13th, 2010, 12:09 PM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Posts: 102
Thanks: 1
Thanked 16 Times in 16 Posts
Send a message via AIM to nberardi
Default

You have the one above. That is all you need for ToUrlFormat()
__________________
Check out my blog at: http://www.coderjournal.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
ToUrlFormat() tedr BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 0 April 12th, 2010 04:29 PM
Where can I change the title? bingb BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 December 25th, 2008 12:21 PM
Get Order By Title ssomchai BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 April 3rd, 2008 09:13 PM
Name or Title charlie3 VBScript 2 July 8th, 2003 05:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.