473,786 Members | 2,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Item DataBound1">
<HeaderTemplate >
<ul>
</HeaderTemplate>
<ItemTemplate >
<li>
<asp:ImageButto n 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_ItemDa taBound1(object sender,
RepeaterItemEve ntArgs e)
{
if (e.Item.ItemTyp e == ListItemType.It em ||
e.Item.ItemType == ListItemType.Al ternatingItem)
{
{
DataRowView drv = (DataRowView)e. Item.DataItem;
string ID = drv["ID"].ToString();
ImageButton myIBTN =
((ImageButton)e .Item.FindContr ol("ibtnSmall") );
myIBTN.ImageUrl = "~/images/pages/customInstalls/
SM/" + ID + ".jpg";
myIBTN.OnClient Click = "javascript:rep laceImg('" +
myIBTN.ImageUrl .Replace("SM", "LG").Replace(" ~", "..") + "');";
imgLarge.ImageU rl = "~/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="JavaS cript">
function replaceImg(path ) {
var Image = document.getEle mentById('imgLa rge');
Image.setAttrib ute("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 2080

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

Similar topics

1
2396
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 contains mostly strings, but one of the Properties of the Direction Class is an image of type System.Web.UI.WebControls.Image. Obviously, if I try to render it in the repeater with the same technique used for a string:
2
1317
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 that will do an image swap on the mouse over event, but I cannot figure out how to get to the parts. I've named them with an Id, but they don't seem reachable by that.
4
9563
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 there is one. So in the repeater there should be someting like: if ( the_image_field <> "" ) then show the image with the filename from the database field end if
1
1270
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 webpage it shows only 1 image... -the repeater displays 2 rows, but it's only the first row that displays the image...
8
3026
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 way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
12
2616
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 than one line and the text simply overlaps the sub-menus below it. I thought i had got around this by placing empty 'spacers' like so; oFoldMenu.make('sub3','')//spacer unfortunately, i have just viewed the site in IExplorer and it has added...
0
1817
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" OnClientClick="location.href='anotherpage.aspx?UserUUID=abc';return false;">Select</asp:LinkButton>
1
1204
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 placed in a repeater Row as a RowContrl
5
2317
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 (multiLanguage). the value of the resource string is saved in a asp:hidden control to be used later in a javascript function, so in the following code ConfirmMessage is a asp:hidden control which saves the value of the properties of the resource...
0
9496
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8989
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.