BUG: Grid DTC Interprets HTML Tag as HTMLID: Q192033
|
The Grid DTC interprets a table containing an HTML tag such as <HR> as HTMLrather than text. In this case a horizontal rule would be displayed in thecells of the DTC Grid rather than the text "<HR>."
All data from a database is put into the DTC Grid as raw text. The browser simply processes this text as though it were any other HTML text.
The best solution is to format the data in the database in the way you want it to appear. If you choose not to format the data in your database so that it appears as HTML source code (see item 3), it will need to be converted (see items 1 and 2).
=Server.HTMLEncode([fieldname])
example: =MyHTMLEncode([field1])(See the example in MORE INFORMATION section).
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
A sample HTMLEscape() function:
// This function is time-consuming and it would be best to avoid
// using it unless it is absolutely necessary.
function myHTMLEncode(stData)
{
// A temporary variable to hold the existing/modified character.
chTemp = "";
// A new string which will be generated from chTemp.
stTemp = "";
// The length of the string being passed in.
nLength = toString(stData).length;
// Go through the string character by character.
for(i = 0; i < nLength; i++)
{
// Get the current character and put it in the temp character.
chTemp = stData.charAt(i);
// You may need to add more special case characters.
switch(chTemp)
{
case "<" : chTemp = "<"; // Replace (<) with (<)
break;
case ">" : chTemp = ">"; // Replace (>) with (>)
break;
case "&" : chTemp = "&"; // Replace (&) with (&)
break;
case '""' : chTemp = """; // Replace (") with (")
break;
default : break; // Do nothing, the current character is
// okay.
}
// Add the temp character to the end of the temp string.
stTemp = stTemp + chTemp;
}
// Return the properly formatted string.
return stTemp;
}
Additional query words:
Keywords : kbCtrl kbVisID600bug kbGrpASP kbDSupport
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: July 13, 1999