Is there a way to abbreviate the aspx below? Specifically, is there a
way to eliminate the response.write syntax and escaped characters?
<%
if (MyObject.SomeBoolean)
{
Response.Write("<div class=\"myclass\">");
Response.Write("You may have won 1,000,000 dollars...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
else
{
Response.Write("<div class=\"error\">");
Response.Write("You should buy more magazines...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
%
Thanks.
BrianIn C#, Not. If you want to have a literal quote in a string you have to place
the \ escape before it.
Regarding not having to type Response.Write so much, try stuffing all your
strings into a StringBuilder instance. At the end, you can write one time:
Response.Write(myStringBuilder.ToString());
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Brian F" wrote:
> Hi everyone -
> Is there a way to abbreviate the aspx below? Specifically, is there a
> way to eliminate the response.write syntax and escaped characters?
> <%
> if (MyObject.SomeBoolean)
> {
> Response.Write("<div class=\"myclass\">");
> Response.Write("You may have won 1,000,000 dollars...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> else
> {
> Response.Write("<div class=\"error\">");
> Response.Write("You should buy more magazines...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> %>
> Thanks.
> Brian
>
0 comments:
Post a Comment