473,791 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onClick in aspImage???

Can someone please tell me how i execute an onClick event in an asp:Image tag!

I want to do the following!

Thanks!

<asp:Image runat="server" ID="ibtnExpandR esource"
ImageUrl="../images/user.gif" onClick="Javasc ript: OnPlusClick(thi s);"
style="cursor:h and;"></asp:Image>
Nov 19 '05 #1
7 1546
Should be able to do that from code.... take out the onclick from aspx and
add the following in your code-behind (this is in c#)

ibtnExpandResou rce.Attributes. Add("onclick", "javascript:OnP lusClick(this); ");

HTH
Dan

"Tim::.." wrote:
Can someone please tell me how i execute an onClick event in an asp:Image tag!

I want to do the following!

Thanks!

<asp:Image runat="server" ID="ibtnExpandR esource"
ImageUrl="../images/user.gif" onClick="Javasc ript: OnPlusClick(thi s);"
style="cursor:h and;"></asp:Image>

Nov 19 '05 #2
Tim::.. wrote:
Can someone please tell me how i execute an onClick event in an
asp:Image tag!

I want to do the following!

Thanks!

<asp:Image runat="server" ID="ibtnExpandR esource"
ImageUrl="../images/user.gif" onClick="Javasc ript: OnPlusClick(thi s);"
style="cursor:h and;"></asp:Image>


In Page_Load, do this:
ibtnExpandResou rce.Attributes. Add("onclick"," javascript:
OnPlusClick(thi s);")

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Nov 19 '05 #3
This looks fine. There is no need to use Attributes in code behind since
there is no server-side onclick event for Image control. What problem are
you experiencing?

Eliyahu

"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:53******** *************** ***********@mic rosoft.com...
Can someone please tell me how i execute an onClick event in an asp:Image tag!
I want to do the following!

Thanks!

<asp:Image runat="server" ID="ibtnExpandR esource"
ImageUrl="../images/user.gif" onClick="Javasc ript: OnPlusClick(thi s);"
style="cursor:h and;"></asp:Image>

Nov 19 '05 #4
The ASP:Image tag is in a templatecolumn within a datagrid!

I don't think this would work???

Any Ideas!

Thanks

"Bob Barrows [MVP]" wrote:
Tim::.. wrote:
Can someone please tell me how i execute an onClick event in an
asp:Image tag!

I want to do the following!

Thanks!

<asp:Image runat="server" ID="ibtnExpandR esource"
ImageUrl="../images/user.gif" onClick="Javasc ript: OnPlusClick(thi s);"
style="cursor:h and;"></asp:Image>


In Page_Load, do this:
ibtnExpandResou rce.Attributes. Add("onclick"," javascript:
OnPlusClick(thi s);")

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Nov 19 '05 #5
Oh. I think you will need to do this in PreRender. Unless ... to Eliyahu's
point, shouldn't it work just by setting the attribute in the asp: tag? I
don't have time to test it myself right now, but did you test before
posting? If so, what happened?

Bob Barrows

Tim::.. wrote:
The ASP:Image tag is in a templatecolumn within a datagrid!

I don't think this would work???

Any Ideas!

Thanks

"Bob Barrows [MVP]" wrote:
Tim::.. wrote:
Can someone please tell me how i execute an onClick event in an
asp:Image tag!

I want to do the following!

Thanks!

<asp:Image runat="server" ID="ibtnExpandR esource"
ImageUrl="../images/user.gif" onClick="Javasc ript:
OnPlusClick(thi s);" style="cursor:h and;"></asp:Image>


In Page_Load, do this:
ibtnExpandResou rce.Attributes. Add("onclick"," javascript:
OnPlusClick(thi s);")

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Nov 19 '05 #6
Ok, I found the time to test it (I was curious). This works fine:

<script type=text/javascript>
function test(obj)
{
alert(obj.paren tElement.parent Element.rowInde x)
}
</script>
....
<asp:TemplateCo lumn>
<ItemTemplate >
<IMG src="../Images/Completed.gif" onclick="test(t his)">
</ItemTemplate>
</asp:TemplateCol umn>

Bob Barrows
Tim::.. wrote:
The ASP:Image tag is in a templatecolumn within a datagrid!

I don't think this would work???

Any Ideas!

Thanks

"Bob Barrows [MVP]" wrote:
Tim::.. wrote:
Can someone please tell me how i execute an onClick event in an
asp:Image tag!

I want to do the following!

Thanks!

<asp:Image runat="server" ID="ibtnExpandR esource"
ImageUrl="../images/user.gif" onClick="Javasc ript:
OnPlusClick(thi s);" style="cursor:h and;"></asp:Image>


In Page_Load, do this:
ibtnExpandResou rce.Attributes. Add("onclick"," javascript:
OnPlusClick(thi s);")

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Nov 19 '05 #7
Heh. This isn't really testing what you were asking about (i just noticed).
Let me try again ... yes it still works:

<asp:TemplateCo lumn>
<ItemTemplate >
<asp:Image id="Image1" runat="server"
ImageUrl="../Images/Completed.gif"
onclick="test(t his)"></asp:Image>
</ItemTemplate>
</asp:TemplateCol umn>

The word "onclick" has the red squiggly underline, but it can safely be
ignored.

Bob Barrows

Bob Barrows [MVP] wrote:
Ok, I found the time to test it (I was curious). This works fine:

<script type=text/javascript>
function test(obj)
{
alert(obj.paren tElement.parent Element.rowInde x)
}
</script>
...
<asp:TemplateCo lumn>
<ItemTemplate >
<IMG src="../Images/Completed.gif" onclick="test(t his)">
</ItemTemplate>
</asp:TemplateCol umn>

Bob Barrows
Tim::.. wrote:
The ASP:Image tag is in a templatecolumn within a datagrid!

I don't think this would work???

Any Ideas!

Thanks

"Bob Barrows [MVP]" wrote:
Tim::.. wrote:
Can someone please tell me how i execute an onClick event in an
asp:Image tag!

I want to do the following!

Thanks!

<asp:Image runat="server" ID="ibtnExpandR esource"
ImageUrl="../images/user.gif" onClick="Javasc ript:
OnPlusClick(thi s);" style="cursor:h and;"></asp:Image>

In Page_Load, do this:
ibtnExpandResou rce.Attributes. Add("onclick"," javascript:
OnPlusClick(thi s);")

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Nov 19 '05 #8

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

Similar topics

1
2486
by: Fredo Vincentis | last post by:
Hi guys, this is not really an ASP question, but some of you might have had experience with this and I thought you migth be able to help me. I require the ASP componentn ASPImage for one of my projects. Unfortunately, my webhost does not have this component installed. If I personally buy it, do you think I will be able to install it on the server, or is that something the webhost has to do? Sorry, I have never had to deal with this...
0
1817
by: Mohamed Hosam | last post by:
I want to use ASPImage to resize photos and show them to user as thumbnails on the fly (I do not want to save them). Any idea how to achieve this? On their page, they advise me to use Response.BinaryWrite, so this is what I did: Response.ContentType = "Image/Jpeg" Response.BinaryWrite Image.FileName Instead of showing the image, it shows the binary contents!! Any help is
8
3690
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function and passes it two parameters. For the life of me I cannot figure out what the error is, but one occurs everytime I click a &%*$&# radio button. Also, the function only alerts the user immediately as to what question/answer they clicked. I am...
17
61445
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to programmatically issue a JavaScript statement which causes the browser to act just like the user clicked on a link in my page. And if that link has an onClick JS event defined, I'd want that onClick event to execute too, exactly the same as if the user...
2
9183
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display in the status bar 'Symantec Corporation' whenever anyone mouses over (onMouseOver) my image or link OR when one clicks while holding the left mouse down (onClick) on the same image or link. Upon releasing the mouse (onMouseOut), the
3
3271
by: Jamie Jackson | last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The onclick event that I'm inserting works correctly in Opera, but not in FF or IE. I'm retroactively adding the statement "return promptBeforeOpening();" FF and IE rewrite it as I would expect them to, but it turns out that that doesn't work (no disclaimer pops up, and the link is not disabled):
0
1296
by: Kelly | last post by:
Help, So I'm doing the common make thumbnails script. to save server space, I don't want to store the thumbnails, so I did the classic break up script. I parse on the main page where it gathers the folders, files and their paths, then I pass them over into the sendbinary.asp page which does all the editing. First of all this works.
2
1606
by: bigmentor | last post by:
Good Morning Folks I have bought and own a copy of ASPImage. Installed on my Internet server. Works like a Dream writing and saving image files containing text. My brain seems to have stopped working. I have tried to write a script that I expect cannot be more than ten lines long. The towel has been thrown in !!
1
1205
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
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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
10201
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
10147
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
9987
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
9023
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
6770
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
5424
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...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.