Da black ninja Da black ninja -4 years ago 108
ASP.NET (C#) Question

Displaying HTML error

I know there is something wrong with formatting the code but I'm not sure what is it.

Not Working :

<div id="item_list">
<div id="item">

<%= LoadItems() %>


LoadItems should return this :

returnString = "<div style=\"cursor: pointer;\" class=\"item\" itemid=\"1670\"> " +
" < div class=\"item_pic\"><img src = \"icons/icon_commerce_anccube_skill.jpg\" alt=\"\" style=\"width: 68px; height: 71px;\"></div>" +
" <div class=\"item_title\"><a href = \"javascript:void(0)\" >< span > Skill Upgrade Pack</span></a></div> " +
"<div class=\"clear\"></div> "+
"<div class=\"item_price\"><span style = \"\" > 2,000 gPotatoes</span></div> </div> ";

Working code :

<div id="item_list">
<div id="item">
<div style="cursor: pointer;" class="item" itemid="1670">
<div class="item_pic"><img src="icons/icon_commerce_anccube_skill.jpg" alt="" style="width: 68px; height: 71px;"></div>
<div class="item_title"><a href="javascript:void(0)"><span>Skill Upgrade Pack</span></a></div>
<div class="clear"></div>
<div class="item_price"><span style="">2,000 gPotatoes</span></div>


Answer Source

Your second div has a space between the < and div. This won't be parsed as a div.

You also have a broken span tag on the third line.

I would imaging this is what is breaking your layout.

If you use single quotes to encapsulate the string rather than doubles you wouldn't need to escape the quotes.


returnString = '<div style="cursor: pointer;" class="item" itemid="1670">' +
               '<div>etc...</div>' +
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download