By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

How to write any string

P: n/a
I have a situation where I call a COM object from ASP that is supposed to
create a file. On occasion, especially during development, the output of
the COM function is an error string rather than the file name. I'd like to
display this error string, regardless of it's contents. Right now,
depending on the error string, I get an error message about missing a
semicolon or some such. I've tried using Encode and Server.HTMLEncode with
no luck.

The ASP code contains two <DIV>'s. The first one is visible and shows an
animated progress bar. The second one is hidden initially. Once the COM
function has returned, the page hides the first <DIV> and populates/unhides
a second <DIV> that either contains the results or an error message.

The ASP code looks like this:

function WriteErrorTable(AErrorMsg)
{
Response.write('\n<script language="javascript"
type="text/javascript">\n');
Response.write('function GetDivContent()\n');
Response.write('{\n');
Response.write(' var vHtmlString = \'\';\n');
Response.write(' vHtmlString += \'<table border="0" cellpadding="2"
cellspacing="1">\';\n');
Response.write(' vHtmlString += \' <tr><td align="center"
style="color: Red;"><b>An error occurred while creating the
report</b></td></tr>\';\n');
Response.write(' vHtmlString += \' <tr><td>&nbsp;</td></tr>\';\n');
Response.write(' vHtmlString += \" <tr><td>' +
Server.HTMLEncode(AErrorMsg) + '</td></tr>\";\n');
Response.write(' vHtmlString += \' <tr><td>&nbsp;</td></tr>\';\n');
Response.write(' vHtmlString += \' <tr><td align="center"
style="color: Red;">Please contact your system
administrator</td></tr>\';\n');
Response.write(' vHtmlString += \'</table>\';\n');
Response.write(' return(vHtmlString);\n');
Response.write('}\n');
Response.write('</script>\n');
}

The source of the page causing the error is:

<script language="javascript" type="text/javascript">
function GetDivContent()
{
var vHtmlString = '';
vHtmlString += '<table border="0" cellpadding="2" cellspacing="1">';
vHtmlString += ' <tr><td align="center" style="color: Red;"><b>An error
occurred while creating the report</b></td></tr>';
vHtmlString += ' <tr><td>&nbsp;</td></tr>';
vHtmlString += " <tr><td>Error - Error: The report could not be created.

(Error writing formula - Invalid formula syntax (Row=10, Col=111,
Formula='if(C10&gt;0,sum(Z10,AB10,AD10,AF10,AH10,A J10,AL10,AN10,AP10,AR10,AT
10,AV10,AX10,AZ10,BB10,BD10,BF10,BH10,BJ10,BL10,BN 10,BP10,BR10,BT10,BV10,BX1
0,BZ10,CB10,CD10,CF10,CH10,CJ10,CL10,CN10,CP10,CR1 0,CT10,CV10,CX10,CZ10,DB10
,DD10)/C10,0)'))</td></tr>";
vHtmlString += ' <tr><td>&nbsp;</td></tr>';
vHtmlString += ' <tr><td align="center" style="color: Red;">Please
contact your system administrator</td></tr>';
vHtmlString += '</table>';
return(vHtmlString);
}
</script>
As you can see on the line "(Error writing formula - Invalid formula syntax
(Row=10, Col=111, Formula='if(C10&gt;0,sum", the '>' symbol in the error
message is being converted to '&gt;' so I'm not sure exactly what HTMLEncode
is doing (or not doing).

tia,

Bob M..
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I finally wound up replacing all CR and LF in the string, and stuck it in a
read-only text area. Works like a charm.

Bob M..
"Bob Murdoch" <ra***********@erols.com> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
I have a situation where I call a COM object from ASP that is supposed to
create a file. On occasion, especially during development, the output of
the COM function is an error string rather than the file name. I'd like to display this error string, regardless of it's contents. Right now,
depending on the error string, I get an error message about missing a
semicolon or some such. I've tried using Encode and Server.HTMLEncode with no luck.

The ASP code contains two <DIV>'s. The first one is visible and shows an
animated progress bar. The second one is hidden initially. Once the COM
function has returned, the page hides the first <DIV> and populates/unhides a second <DIV> that either contains the results or an error message.

The ASP code looks like this:

function WriteErrorTable(AErrorMsg)
{
Response.write('\n<script language="javascript"
type="text/javascript">\n');
Response.write('function GetDivContent()\n');
Response.write('{\n');
Response.write(' var vHtmlString = \'\';\n');
Response.write(' vHtmlString += \'<table border="0" cellpadding="2"
cellspacing="1">\';\n');
Response.write(' vHtmlString += \' <tr><td align="center"
style="color: Red;"><b>An error occurred while creating the
report</b></td></tr>\';\n');
Response.write(' vHtmlString += \' <tr><td>&nbsp;</td></tr>\';\n');
Response.write(' vHtmlString += \" <tr><td>' +
Server.HTMLEncode(AErrorMsg) + '</td></tr>\";\n');
Response.write(' vHtmlString += \' <tr><td>&nbsp;</td></tr>\';\n');
Response.write(' vHtmlString += \' <tr><td align="center"
style="color: Red;">Please contact your system
administrator</td></tr>\';\n');
Response.write(' vHtmlString += \'</table>\';\n');
Response.write(' return(vHtmlString);\n');
Response.write('}\n');
Response.write('</script>\n');
}

The source of the page causing the error is:

<script language="javascript" type="text/javascript">
function GetDivContent()
{
var vHtmlString = '';
vHtmlString += '<table border="0" cellpadding="2" cellspacing="1">';
vHtmlString += ' <tr><td align="center" style="color: Red;"><b>An error
occurred while creating the report</b></td></tr>';
vHtmlString += ' <tr><td>&nbsp;</td></tr>';
vHtmlString += " <tr><td>Error - Error: The report could not be created.
(Error writing formula - Invalid formula syntax (Row=10, Col=111,
Formula='if(C10&gt;0,sum(Z10,AB10,AD10,AF10,AH10,A J10,AL10,AN10,AP10,AR10,AT 10,AV10,AX10,AZ10,BB10,BD10,BF10,BH10,BJ10,BL10,BN 10,BP10,BR10,BT10,BV10,BX1 0,BZ10,CB10,CD10,CF10,CH10,CJ10,CL10,CN10,CP10,CR1 0,CT10,CV10,CX10,CZ10,DB10 ,DD10)/C10,0)'))</td></tr>";
vHtmlString += ' <tr><td>&nbsp;</td></tr>';
vHtmlString += ' <tr><td align="center" style="color: Red;">Please
contact your system administrator</td></tr>';
vHtmlString += '</table>';
return(vHtmlString);
}
</script>
As you can see on the line "(Error writing formula - Invalid formula syntax (Row=10, Col=111, Formula='if(C10&gt;0,sum", the '>' symbol in the error
message is being converted to '&gt;' so I'm not sure exactly what HTMLEncode is doing (or not doing).

tia,

Bob M..

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.