Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 8th, 2008, 02:19 AM
Registered User
 
Join Date: Mar 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help, what code should I write here?

when mouse over the hotspot, IE status bar displayed "Error on Page".

my code as below:

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="?????????" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
<form id="Display_Sample" action="~/products.aspx" method="POST">
<table style="width:450px;height:550px">
    <tr style="width:100%; height:450px">
    <td>
   <asp:image id="DisplayProduct" runat="server" ImageUrl="~/Images/Sample_CanadianWinter.gif" AlternateText="???"/>
    </td>
    </tr>
    <tr style="width:100%; height:100px"><td>
    <img style="border:0" id="Product_Grid" runat="server" src="~/Images/Sample_Grid10Ft.gif" mce_src="~/Images/Sample_Grid10Ft.gif" usemap="#DisplayProductPallet" alt=""/>
    </td>
    </tr>
</table>
    <map id="DisplayProductPallet">
    <area shape="rect" coords="5,5,100,105" href="http://forums.asp.net/AddPost.aspx?ForumID=15#" mce_href="http://forums.asp.net/AddPost.aspx?ForumID=15#" alt="Canadian Winter"
    onmouseover="window.document.Content1.ContentPlace Holder1.Display_Sample.DisplayProduct.ImageUrl='~/Images/Sample_CanadianPaint.gif'"/>
    </map>
</form>

</asp:Content>

is it correct I am using window.document...?


 
Old March 10th, 2008, 10:07 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The problem here is that the client knows nothing about .NET. Therefore, using an object oriented naming pattern has no meaning. Look are the emitted HTML for this page and you are going to see something much different in the image control's name and ID attribute. However, don't just use what you see there as it might change depending on the behavior of the page (those are names generated by the ASP.NET runtime). Ideally, you should write some codebehind to emit the javascript with the unique client ID of the image control. You might be able to get away with something like this:

<area shape="rect" coords="5,5,100,105" href="http://forums.asp.net/AddPost.aspx?ForumID=15#" mce_href="http://forums.asp.net/AddPost.aspx?ForumID=15#" alt="Canadian Winter" onmouseover="<%=DisplayProduct.ClientID%>.url='~/Images/Sample_CanadianPaint.gif'"/>

This should emit the DisplayProduct image control unique clientID to the area tag.

-Peter
peterlanoie.blog
 
Old March 10th, 2008, 10:09 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Oh, and I had something wrong... it should be ".src" not ".url" for the client side image url attribute of the image. Also, using the ~ syntax in the client side doesn't work either. You need to fully qualify the image URL.

Try this:

<area shape="rect" coords="5,5,100,105" href="http://forums.asp.net/AddPost.aspx?ForumID=15#" mce_href="http://forums.asp.net/AddPost.aspx?ForumID=15#" alt="Canadian Winter" onmouseover="<%=DisplayProduct.ClientID%>.src='<%= ResolveUrl("~/Images/Sample_CanadianPaint.gif")%>'"/>

-Peter
peterlanoie.blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i write code to go back or undo sanderson Beginning VB 6 1 July 9th, 2008 05:10 PM
re write a code kgoldvas XSLT 3 August 1st, 2007 07:40 AM
how write vb code in c# ravpaw General .NET 2 July 1st, 2007 02:13 PM
How to write code to draw bouncing circles Bimbo VB How-To 1 November 11th, 2005 02:17 PM
Can I write ASP code in Dreamweaver? Ben Horne Dreamweaver (all versions) 13 December 4th, 2003 04:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.