Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
  #2 (permalink)  
Old April 13th, 2010, 10:17 AM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Location: Phoenixville, PA, USA
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
  #3 (permalink)  
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()
  #4 (permalink)  
Old April 13th, 2010, 11:04 AM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Location: Phoenixville, PA, USA
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
  #5 (permalink)  
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();
}
  #6 (permalink)  
Old April 13th, 2010, 11:12 AM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Location: Phoenixville, PA, USA
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
  #7 (permalink)  
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.
  #8 (permalink)  
Old April 13th, 2010, 11:37 AM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Location: Phoenixville, PA, USA
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
  #9 (permalink)  
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?
  #10 (permalink)  
Old April 13th, 2010, 12:09 PM
nberardi's Avatar
Wrox Author
 
Join Date: Aug 2008
Location: Phoenixville, PA, USA
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.