Friday, 15 May 2015

asp.net - Input string was not in a correct format in replace mehod -



asp.net - Input string was not in a correct format in replace mehod -

i want edit text , there dynamic fields in it, used replace method have these fields in special place in context. problem when want replace these fields in context gave me error: input string not in right format. error happen in emailbody. , content of body variable this:

from: {journalabbreviation} &lt; {journalabbreviation}@test.com&gt;<br /> subject: review submitted {journalabbreviation}<br /> body:<br /> manuscript id:&nbsp; {manuscriptid}<br /> title: {title}<br /> <br /> <br /> dear {prefix} {firstname} {middlename} {lastname},<br /> <br /> give thanks review {journalabbreviation}. appreciate time , feedback , hope collaborate 1 time again in near future.<br /> <br /> kind regards,<br /> {firstnamesender}, phd<br /> associate editor<br /> {journalfullname}<br /> http://{journalabbreviation}.test.com<br /> <br />

this code has been saved string in database , body variable fill these code.

body = body.replace("{prefix}", "{0}"); body = body.replace("{firstname}", "{1}"); body = body.replace("{middlename}", "{2}"); body = body.replace("{lastname}", "{3}"); body = body.replace("{manuscriptid}", "{4}"); body = body.replace("{title}", "{5}"); body = body.replace("{journalabbreviation}", "{6}"); body = body.replace("{fulljournalname}", "{7}"); body = body.replace("{prefixsender}", "{8}"); body = body.replace("{firstnamesender}", "{9}"); body = body.replace("{middlenamesender}", "{10}"); body = body.replace("{lastnamesender}", "{11}"); string **emailbody** = string.format(body, prefix, firstname, middlename, lastname, manuscriptid, title, journalabbreviation, fulljournalname, prefixsender, firstnamesender, middlenamesender, lastnamesender);

the print out is:

from: ieee < ieee@test.com> subject: review submitted ieee

manuscript id: 102-ieee-2013 title: text mining using biclustering method international electrical engineering science

dr john smith,

a review has been submitted above-mentioned manuscript.

kind regards, international electrical engineering science http://ieee.test.com

can body help me find the problem? thanks

i see in body have {journalfullname} , not alter number anywhere on replace, (and other this) give error.

to avoid error ether alter parameter {{journalfullname}} ether sure replace because symbols {} wait have number within reflect parameter on format.

asp.net replace string-formatting

No comments:

Post a Comment