c# - string.Format exception Input string was not in a correct format -
i received following error string.format(...)
operation:
system.formatexception - input string not in correct format.
i have resource dictionary contains entry basic html page.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>title of document</title> <style> * { margin: 0; padding: 0; } body { font-family: 'arial, verdana', fallback, sans-serif; font-size: 14px; } table { background-color: #eeeeee; width: 100%; padding: 10px; margin: 5px; } h1 { font-size: 16px; font-weight: bold; margin: 20px 0 10px 0; } </style> </head> <body> text<br /> <table> <tr> <td>text 1</td> <td>{0}</td> </tr> <tr> <td>text 2</td> <td>{1}</td> </tr> <tr> <td>text 3</td> <td>{2}</td> </tr> <tr> <td>text 4</td> <td>{3}</td> </tr> <tr> <td>text 5</td> <td>{4}</td> </tr> <tr> <td>text 6</td> <td>{5}</td> </tr> <tr> <td>text 7</td> <td>{6}</td> </tr> </table> <br /> <h1>header1</h1> <table> <tr> <td><a href="http://www.google.com">http://www.google.com</a></td> </tr> <tr> <td>text 8: {7}</td> </tr> </table> <br /> </body>
the string.format(...)
operations looks this:
var emailhtml = string.format( webutility.htmlencode(emailresource.emailtemplate), "text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8");
does know error made? isn't possible fill in placeholders in resource dictionary this?
you have lot of curly braces not format specifiers, example:
{ margin: 0; padding: 0; }
either need duplicate them:
{{ margin: 0; padding: 0; }}
or using different formatting approach (like template engine).
Comments
Post a Comment