473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

OnClientClick in Repeater Control Flashing Javascript Image Swap

Hi Guys,

I have this about 98% done and I cannot get it work properly. I have a
Repeater bound to a MySQL DataSource, inside the Repeater I have an
ImageButton, outside the repeater I have a Image, code is below:

<asp:Image ID="imgLarge" Name="imgLarge" runat="server"
AlternateText="Large Custom Image" Height="300" Width="400" />
<asp:Repeater ID="rptSmall" runat="server"
OnItemDataBound="rptSmall_ItemDataBound1">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:ImageButton ID="ibtnSmall" runat="server"
Height="79" Width="105" />
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>

The OnItemDataBound command is setting the ImageURL and OnClientClick
command:
protected void rptSmall_ItemDataBound1(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
{
DataRowView drv = (DataRowView)e.Item.DataItem;
string ID = drv["ID"].ToString();
ImageButton myIBTN =
((ImageButton)e.Item.FindControl("ibtnSmall"));
myIBTN.ImageUrl = "~/images/pages/customInstalls/
SM/" + ID + ".jpg";
myIBTN.OnClientClick = "javascript:replaceImg('" +
myIBTN.ImageUrl.Replace("SM", "LG").Replace("~", "..") + "');";
imgLarge.ImageUrl = "~/images/pages/customInstalls/
LG/" + ID + ".jpg";
}
}
}

When the ImageButton is clicked it should change the large image
(imgLarge) to the small image being clicked with the javascript below:
<script type="text/javascript" language="JavaScript">
function replaceImg(path) {
var Image = document.getElementById('imgLarge');
Image.setAttribute("src", path);
}
</script>

For some reason, the large image (imgLarge) is only flickering to the
selected image and then going back to the default URL. if (!
Page.IsPostBack) is at the top of the Page_Load. Any ideas would
really be helpful.

Thanks in Advance,
Sully
Jun 27 '08 #1
0 2044

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Law | last post by:
Hi, I have a repeater in my vb.net page which needs to render an image control (it's a mappoint linedrive map image). The repeater itself is bound to an array of object 'Directions' which ...
2
by: No One | last post by:
I have a custom webcontrol that displays a menu bar consisting of a table with images. Each image as a link. The parts are made of Web controls, not straight html. I need to write a Javascript...
4
by: nicholas | last post by:
Got an asp.net data-repeater on my page. I can view the texts from the database (ex.: <%# Databinder.Eval(Container.DataItem, "contentEN") %> ), but I also would like to see the image, but only if...
1
by: Jeff | last post by:
Hey asp.net 2.0 I have a repeater control in my webpage (you see my code below). In this control's ItemDataBound event I set the ImageUrl of a Image object. My problem is that when I run this...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
12
by: tim | last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus in firefox. On my sub3 menus i have more than one line of text in some places. firefox does not recognise that there is more...
0
by: sloan | last post by:
Asp.Net 2.0 Inside a repeater, I'm trying to do a linkbutton with a OnClientClick <asp:LinkButton ID="lnbSelect" runat="server"...
1
by: himanshu110 | last post by:
HI guys im fed up with this help me The problem is.. Im having a repeater control in which im having a aspImage Control imgAImageUpload"]..just near to it is a href placed Both are...
5
by: =?Utf-8?B?Y3lydXM=?= | last post by:
Hi everybody, I have created a simple web form which contains a repeater. every item of the repeater has a button to delete the tiem. my web form uses Resource files to globalizing the form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.