views:

279

answers:

1

I have the following html:

<a href="javascript:<%# 'js code' %>" class="MyClass">
<div class="HeaderRow" style="vertical-align:middle;text-align:left;height:35px;width:998px;">
<b style="vertical-align:middle;"><%# ((MyObject)Container.DataItem).Name %></b>: <%# ((MyObject)Container.DataItem).ImageSrc%>
</div>
<p style="margin-left:10px;"><%# ((MyObject)Container.DataItem).Notes%></p>
</a>

It renders properly. However, when I try to click on the image provided by ((MyObject)Container.DataItem).ImageSrc, nothing happens. If I click anywhere else within the page, the links works fine. What's happening here?

A: 

Why don't you make your image or div clickable?

<div class="HeaderRow" 
     style="vertical-align:middle;text-align:left;height:35px;width:998px;" 
     onclick="<%# 'js code' %>">
    <p style="vertical-align:middle;">
        <strong><%# ((MyObject)Container.DataItem).Name %>:</strong>
        <%# ((MyObject)Container.DataItem).ImageSrc%>
    </p>
</div>
<p style="margin-left:10px;">
    <%# ((MyObject)Container.DataItem).Notes%>
</p>

Try to avoid non semantic elements (span, div, b, i, blink) when making your html.

voyager
I am curious, what is wrong with "non-semantic elements"?Thanks!
laconicdev
http://en.wikipedia.org/wiki/HTML#Semantic_HTML http://semantichtml.org/home/http://www.joedolson.com/articles/2008/04/why-use-semantic-html/http://www.thefutureoftheweb.com/blog/writing-semantic-htmlIt brings advantages to you, when you want the page to look different (you just change the css), to people with accesibility problems, because they can override your css, and to search engines because they can better index your site.
voyager