Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to call a javascript function on mouseover of div, the div is dynamically created in asp.net. my code is:
XML
strRet.Append("<div class='col_1_of_3 span_1_of_3 tryathome-container'>")
               strRet.Append("<div class='inner_content clearfix'>")
               strRet.Append("<div class='product_image'>")
               strRet.Append("<a class='product-image' href='productdetails.aspx?id=" & encrPvCode & "&url=productlist.aspx?" & IIf(String.IsNullOrWhiteSpace(cid), "", "id=" & encrCatId) & IIf(String.IsNullOrWhiteSpace(pid), "", "&pid=" & encrPvCode) & "'>")
               strRet.Append("<input type='hidden' id='hdnPvCode" & i.ToString & "' value='" & PvCode & "'/>")
               strRet.Append("<img src='" & imgSrc & "' alt='' />")
               strRet.Append("</a>")
               strRet.Append("<div class='product_hover_option'>")



i want to call the alert on


please suggest me code, how and where can i write that code.

thanks in advance
Posted

1 solution

Define your mouse over function in javascript(On Page) before you are going to append your div string into page.

JavaScript
function myMouseMover()
{
alert('Mouse Over');
}


while appending string just add the onmouseover attribute to you div as below.
C#
strRet.Append("<div class="col_1_of_3 span_1_of_3 tryathome-container" onmouseover="myMouseover()">")</div>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900