Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...Javascript Challenge! (image blow up on mouseover of asp:HyperLink in asp:DataGrid)Javascript Challenge! (image blow up on mouseover of asp:HyperLink in asp:DataGrid)
Previous
 
Next
New Post
10/25/2006 12:57 PM
 

(This is not strictly speaking a skinning question, but its the closest match I could think of)

I have a module that I want to customize so that each image in a list of images, when moused over generates a floating enlarged version of the same image (e.g. a list of thumbnails which when moused over show a full size image). I know how to do this in pure HTML and Javascript, the challenge is that I only have access to the ASCX file of the module (no source code) and the ASP.NET code is rendering the images using asp:HyperLink controls withn an asp:DataGrid !

The Javascript I would normally use uses document.getElementById or document.getElementsByName to find the <IMG> then sets the SRC property of my floating image.

Here's where the problem starts:

The list of images is created by an asp:DataGrid control. Each image is created by an asp:Hyperlink control, like this:

<asp:HyperLink Runat="server" id="hypgridmoreinfo" name="hypgridmoreinfo" Runat="server" BorderWidth="0" onmouseover="return enlarge(event,'center', 730, 740)"/></TD>

This causes 2 problems:

  1. The resulting HTML looks like this

    <a id="dnn_ctr1691_ProductPage_grdProducts__ctl2_hypgridmoreinfo" name="hypgridmoreinfo" onmouseover="return enlarge(event,'center', 730, 740)" href="/CriteriaInc/tabid/163/CategoryID/0/List/1/Level/a/ProductID/4/Default.aspx" style="border-width:0px;">

    <IMG src="/portals/1/image1.gif" align="" border="0">
    </a>

    ... so the IMG I need to retrieve the SRC of has no ID and no NAME either, so how to reference it?

  2. If I could somehow reference the IMG via the <A> link, the ID has been "transformed" by DNN into a different ID than the one specified in the ASCX. The NAME has been preserved but will be the same for every image in the list.

So, is there a solution? Remember I need a solution that only involves altering the ASCX file of the module!

 
New Post
10/25/2006 6:53 PM
 

I would send the id of the grid down to the client by modifying the ASCX

something like

var m_sGrd = '<%=Me.hypgridmoreinfo.ClientID%>';

Or using a

<SCRIPT runat="server">

to do the same thing.

Once you have the reverence to the grid

var oGrd = document.getElementById(m_sGrd);

Now that you have the grid you can easily loop its child nodes

for (var i=0; i<oGrd.childNodes.length; i++)

{

  //this will get you the A elements (I assume).  Its childNodes[0] will contain your IMG

}

 

 

By the way, this could have been a post in the ClientAPI, though not specific to it.

 


 
New Post
10/26/2006 1:01 PM
 

Thanks for this, but I am not sure how to make use of it.

Your approach is to get a reference to the grid, then loop through the hyperlinks in it and get the SRC of the IMG within each hyperlink. If I add this code to my "enlarge" function (which is called on mouseover of a particular image, and which generates the blown up image) how do I know which is the image that was just mouseover'd, i.e. when to get out of the loop?

I think what I need is some code that I can attach to the asp:hyperlink within the asp:datagrid, that passes the ID of the hyperlink to my javascript "enlarge" function.

I tried doing this:

<asp:HyperLink Runat="server" id="hypgridmoreinfo" name="hypgridmoreinfo" Runat="server" BorderWidth="0" onmouseover="return enlarge(<%=Me.hypgridmoreinfo.ClientID%>, event,'center', 730, 740)"/>

... i.e. adding an ID parameter to the enlarge function, but it looks like you can't add a <% %> block inside an ASP control.

Any more ideas? Thanks for looking at this.

 
New Post
10/26/2006 5:05 PM
 

I would have thought that getting a reference to the image object would be enough and you could modify your enlarge function (or make a new one) that would accept the img instead of the ID.

I suppose if you are in need of the IMG having an ID you could simply assign them on the client side.  Just make sure you prefix them with a "safe" namespace (the grid id would probably be save...  grdid_1, grdid_2).

To restate what I think could be done (all on client). 

1) Get reference to grid object

2) Loop through each child A element or IMG element

3) Either assign an id to the IMG or make a new enlarge that allows the element to be passed

4) add you onmouseover event handler  to the IMG element


 
New Post
11/1/2006 12:20 PM
 

I finally got it working. It was actually easier than I thought. First I added a "sourceobj" argument to my enlargeimg function for the reference to the <A> element. Then I got the reference to the <IMG> element's src using Jon's advice:

destobjimgsrc=sourceobj.childNodes[0].src

In the <asp:HyperLink> where the function is called, I used the "this" variable to pass in the reference to the <A> element:

<asp:HyperLink id="hyplistmoreinfo" Runat="server" onmouseover="return enlargeimg(this, event,'center', 300, 300)"></asp:HyperLink>

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...Javascript Challenge! (image blow up on mouseover of asp:HyperLink in asp:DataGrid)Javascript Challenge! (image blow up on mouseover of asp:HyperLink in asp:DataGrid)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out