Reputation: 3849
I'm using an HtmlHelper where I give table data id's based on day and month values which are retrieved. The problem is the id is not recognized in the format it's in. '/'
seems to not be picked up yet when I replace '/' with '-' it works.
daysRow.AppendFormat("<td id='{0}/{1}'>{0}</td>", day, d1.Month.ToString());
Can anyone tell me how to format this?
Upvotes: 0
Views: 13169
Reputation: 4836
Use // iirc
alternativley i think putting @ in front of your string will make it be tret as a literal.
eg
string s = @"\w\e\r\ty";
or
string s = "d\\d";
what you need to use is the string literal
'& # 4 7 ;' without the spaces
instead of the forward slash
Upvotes: -4
Reputation: 4511
I think you are using an invalid character, certainly according to this SO question it appears that you cant use forward slashes.
Upvotes: 0
Reputation: 74530
The problem is not with C#, but rather, with your using a '/' character in HTML. From the section of the HTML 4.0 spec on the id attribute:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
The '/' violates that rule, which is why you are seeing issues when using that, but not the '-' character.
Upvotes: 14