How to enlarge image on mouseover in gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lisles
    New Member
    • Jan 2010
    • 40

    #1

    How to enlarge image on mouseover in gridview

    hi;

    Im using a gridview to display images in 1 of the column...but the size of the images is very small.is there anyway to enlarge the image on mouseover or even without mouseover by adjusting the column width or something.i would prefer doing it by mouseover.can anybody help me...my code is below

    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="news_evnts.aspx.cs" Inherits="news_evnts" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Prison Department, Goa</title>
        <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
    
        <script language="javascript" type="text/javascript">
        function txtChk(){txtChanged('u'); txtChanged('p');}
    		function txtChanged(s){if(s=='u'){if(document.getElementById("txtEmail").value=="" || document.getElementById("txtEmail").value=="Login Id"){document.getElementById("txtEmail").value="Login Id";	document.getElementById("txtEmail").style.color="#aca899";}}
    		else if (s=='p') {if(document.getElementById("txtPass").value=="" || document.getElementById("txtPass").value=="Password"){document.getElementById("txtPass").value="Password";document.getElementById("txtPass").style.color="#aca899";}}}
    		function txtClick(s){if(s=='u'){if(document.getElementById("txtEmail").value=="Login Id"){	document.getElementById("txtEmail").value="";document.getElementById("txtEmail").style.color="#000000";	}}
    		else if(s=='p'){if(document.getElementById("txtPass").value=="Password"){	document.getElementById("txtPass").value="";document.getElementById("txtPass").style.color="#808080";}}}
      
      
    			var lastColorUsed, colUsed;
    			
    			function dg_changeBackColor(row, highlight)
    			{
    				if (highlight)
    				{
    					lastColorUsed = row.style.backgroundColor;
    					colUsed =  row.style.color;
    					
    					row.style.backgroundColor ='DimGray';//"#F7F7F7";// 'papayawhip';
    					row.style.color = 'Blue';
    					row.style.cursor='hand';
    				}
    				else
    				{			
    					row.style.backgroundColor = lastColorUsed;
    					row.style.color = colUsed;
    				}
    			}
    			
    			function stopPost()
    			{
    				return false;
    			}
    			
    		
    
        </script>
    
        <script language="JavaScript" type="text/javascript">
    			var newBg;
    			function changeHl(strId)
    			{
    			   newBg = "images/HlImg/"+strId+".jpg";
    			   document.getElementById("imgHL").src = newBg;		  
    			}
    			function setURL()
    			{
    		   var param = "height="+screen.height+",width="+screen.width+",resizable=yes,status=yes,toolbar=no,menubar=no,screenX=0,screenY=0,left=0,top=0";
    			   var s =  document.getElementById("ctl00_txtFilePath").value ;	
    			  window.open(s,"citizenchart",param);
    			   
    			}
        </script>
    
    </head>
    <body>
        <form id="mst" runat="server">
            <div id="wrapper">
                <div id="header">
                    <div style="color: #FFFFFF; font-family: 'Maiandra GD', 'Trebuchet MS', Tahoma, Verdana;">
                        <table id="tbl" width="100%">
                            <tr>
                                <td align="center" style="width: 145px">
                                    <img src="images/bg_charity1.jpg" alt="gov" style="width: 76px; height: 84px" /></td>
                                <td>
                                    <div style="font-size: 24px;">
                                        Inspector General of Prisons</div>
                                    <div style="font-size: 16px;">
                                        Government of Goa</div>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="navlist">
                        <ul id="Ul1">
                            <li><a id="hm" runat="server" href="index.aspx">Home</a></li>
                            <%--<li><a id="hm" href="index.html">Home</a></li>--%>
                            <li><a id="au" runat="server" href="AboutUs.aspx">About Us</a></li>
                            <li><a id="am" runat="server" href="Amenities.aspx">Amenities</a></li>
                            <li><a id="ne" runat="server" href="news_evnts.aspx">News & Events</a></li>
                            <li><a id="pr" runat="server" href="jailproducts.aspx">Products</a></li>
                            <li><a id="rti" runat="server" href="rghtoinfrmtn.aspx">R. T. I.</a></li>
                            <li><a id="cc" runat="server" href="remission.aspx">Remission</a></li>
                            <li><a id="fb" runat="server" href="Default2.aspx">Feedback</a></li>
                            <li><a id="cu" runat="server" href="contact.aspx">Contact Us</a></li>
                        </ul>
                    </div>
                </div>
                <div id="headline">
                    <div id="photo">
                        <div>
                            <img src="images/igp.gif" width="618" height="250" alt="Pic 1" />
                        </div>
                    </div>
                    <div id="search-news" style="height: 248px">
                        <h2 class="downcast">
                            Quick Links</h2>
                        <br />
                        <div id="plussbullets">
                            <asp:HiddenField ID="txtFilePath" runat="server" />
                            <%--    <asp:TextBox ID="txtFilePath" runat="server" Width="71px"  ></asp:TextBox>--%>
                            <ul>
                                <%--  <li> <asp:LinkButton ID="lbStats" runat="server" OnClick="stats_Click" >Prison Statistics</asp:LinkButton></li>--%>
                                <%--<li><asp:HyperLink ID="HyperLink1" runat="server"  OnClick="stats_Click">Prison Statistics</asp:HyperLink></li>--%>
                                <%-- <li><a href="" onclick="stats_Click">
                                  Prison Statistics  </a></li>--%>
                                <li><a id="A1" href="" runat="server" onclick="setURL();" target="_blank">Prison Statistics</a></li>
                                <li><a href="rightsandduties.aspx">Rights & Duties of Prisoners</a></li>
                                <li><a href="reformation.aspx">Jail Reformation</a></li>
                                <li><a href="Citizen_new.pdf" target="_blank">Citizen's Charter</a></li>
                                <li><a href="listaddoff.aspx">List of area wise offices and Judicial Lock-Ups</a></li>
                                <li><a href="orgchart.aspx">Organisational Setup</a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div id="body">
                    <div class="info">
                        News and Events</div>
                    <br />
                    <div id="body-left">
                        <div style="height: 270px; width: 163px; overflow: Auto">
                            <asp:DataList ID="dlEvents" runat="server" Width="90%" GridLines="both" CellPadding="5"
                                OnItemCommand="getSelected" DataKeyField="prison_event_title">
                                <%--OnItemDataBound="ItemDataBound"OnSelectedIndexChanged="SelectedIndexChanged"--%>
                                <HeaderStyle BackColor="#5C5C5C" BorderColor="#859D31" BorderStyle="solid" BorderWidth="1px"
                                    Font-Names="Tahoma, Verdana, sans-serif" Font-Bold="true" Font-Size="11px" ForeColor="white" />
                                <SelectedItemStyle BackColor="white" ForeColor="#99A866" />
                                <HeaderTemplate>
                                    Titles
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:LinkButton ID="Linkbutton1" runat="server" CommandName="select" Text='<%# Bind("prison_event_title") %>' />
                                </ItemTemplate>
                                <ItemStyle BackColor="white" ForeColor="#99A866" />
                            </asp:DataList>
                        </div>
                    </div>
                    <div id="body-right" style="width: 351px">
                        <%-- <asp:DataList ID="dlEvntImages" runat="server" Visible="false">
                            
                            <ItemTemplate>
                        <asp:Image runat="server" ID="evntImage">
                            </asp:Image>
                  
                                <asp:Label ID="lblMsg" runat="server"  Text='<%# Bind("prison_eventDtl_description") %>'></asp:Label>
                                   <asp:Label ID="lblId" runat="server" Visible="false" Text='<%# Bind("prison_event_id") %>'></asp:Label>
                                      <asp:Label ID="lblKey" runat="server" Visible="false" Text='<%# Bind("prison_eventDtl_srno") %>'></asp:Label>
                        </ItemTemplate>
                        </asp:DataList>--%>
                        <table id="tblEvntDetails" runat="server" border="1" visible="false">
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <div style="height: 200px; overflow: auto;">
                                        <asp:GridView ID="gvDocuments" runat="server" HorizontalAlign="Left" Width="98%"
                                            EmptyDataText="No records found" AutoGenerateColumns="False" BackColor="White"
                                            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="1" ForeColor="Black"
                                            Height="18px">
                                            <Columns>
                                                <asp:TemplateField HeaderText="Event Id" Visible="False">
                                                    <ItemTemplate>
                                                        <asp:Label ID="gvLblId" runat="server" Text='<%# Bind("prison_event_id") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Image Id" Visible="False">
                                                    <ItemTemplate>
                                                        <asp:Label ID="gvLblSrNo" runat="server" Text='<%# Bind("prison_eventDtl_srno") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Image">
                                                    <ItemTemplate>
                                                        <asp:Image ID="Image1" Height="40" Width="40" runat="server" ImageUrl='<%# "~/ASHX/ImageHandler.ashx?__KEY="+ Eval("prison_event_id")+"&__imgId="+Eval("prison_eventDtl_srno") %>' />
                                                    </ItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" />
                                                    <ItemStyle Height="200px" Width="200px" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Description">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblDesc" runat="server" Text='<%# Bind("prison_eventDtl_description") %>'
                                                            Width="200px"></asp:Label>
                                                    </ItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" />
                                                    <ItemStyle Height="200px" Width="400px" />
                                                </asp:TemplateField>
                                            </Columns>
                                            <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
                                            <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
                                            <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
                                            <AlternatingRowStyle BackColor="White" />
                                            <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
                                        </asp:GridView>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1">
                                    <asp:Label ID="lblTitle" runat="server" Text="Title" Visible="false" Font-Bold="true"></asp:Label></td>
                                <td colspan="3">
                                    <asp:Label ID="lblEvntTitle" runat="server" Text='<%# Eval("prison_event_title") %>'
                                        Visible="false"></asp:Label></td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="lblEvntId" runat="server" Text='<%# Eval("prison_event_id") %>' Visible="false"></asp:Label></td>
                            </tr>
                            <tr>
                                <td colspan="1">
                                    <asp:Label ID="lblDate" runat="server" Text="Date" Visible="false" Font-Bold="true"></asp:Label></td>
                                <td colspan="4">
                                    <asp:Label ID="lblEvntDate" runat="server" Text='<%# Eval("prison_event_date") %>'
                                        Visible="false"></asp:Label></td>
                            </tr>
                            <tr>
                                <td colspan="1">
                                    <asp:Label ID="lblVenue" runat="server" Text="Venue" Visible="false" Font-Bold="true"></asp:Label></td>
                                <td colspan="4">
                                    <asp:Label ID="lblEvntVenue" runat="server" Text='<%# Eval("prison_event_venue") %>'
                                        Visible="false"></asp:Label></td>
                            </tr>
                            <tr>
                                <td colspan="1">
                                    <asp:Label ID="lblDesc" runat="server" Text="Description" Visible="false" Font-Bold="true"></asp:Label></td>
                                <td colspan="4">
                                    <div style="height: 50px; overflow: auto;">
                                        <asp:Label ID="lblEvntDesc" runat="server" Text='<%# Eval("prison_event_description") %>'></asp:Label>
                                        <%--<asp:TextBox ID="txtEvntDesc" runat="server" Text='<%# Eval("prison_event_description") %>'
                                        ReadOnly="true" Visible="false"></asp:TextBox>--%>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                &nbsp;
                <p>
                </p>
                <div class="clear">
                </div>
            </div>
            <div id="footer">
                <p>
                    &copy; 2009 all rights reserved.</p>
                <p>
                    Developed &amp; Maintained by Goa Electronics Limited
                </p>
                <p>
                    www.goaelectronics.co.in</p>
            </div>
        </form>
    </body>
    </html>
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    No where in your code (that I can see) do you have any JavaScript that handles the mouseover event. You need to implement a method that does so.

    If you don't want the image resize to have an effect on your column width then, in the method that handles the mouseover event for the image, set the image's position to "absolute". This will remove the image from the natural flow of the page so that when you resize it, the column will not be affected.

    -Frinny

    Comment

    Working...