473,399 Members | 4,254 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,399 software developers and data experts.

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="ibtnExpandResource"
ImageUrl="../images/user.gif" onClick="javascript: OnPlusClick(this);"
style="cursor:hand;"></asp:Image>
Nov 19 '05 #1
7 1528
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#)

ibtnExpandResource.Attributes.Add("onclick", "javascript:OnPlusClick(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="ibtnExpandResource"
ImageUrl="../images/user.gif" onClick="javascript: OnPlusClick(this);"
style="cursor:hand;"></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="ibtnExpandResource"
ImageUrl="../images/user.gif" onClick="javascript: OnPlusClick(this);"
style="cursor:hand;"></asp:Image>


In Page_Load, do this:
ibtnExpandResource.Attributes.Add("onclick","Javas cript:
OnPlusClick(this);")

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_hotmail.com> wrote in message
news:53**********************************@microsof t.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="ibtnExpandResource"
ImageUrl="../images/user.gif" onClick="javascript: OnPlusClick(this);"
style="cursor:hand;"></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="ibtnExpandResource"
ImageUrl="../images/user.gif" onClick="javascript: OnPlusClick(this);"
style="cursor:hand;"></asp:Image>


In Page_Load, do this:
ibtnExpandResource.Attributes.Add("onclick","Javas cript:
OnPlusClick(this);")

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="ibtnExpandResource"
ImageUrl="../images/user.gif" onClick="javascript:
OnPlusClick(this);" style="cursor:hand;"></asp:Image>


In Page_Load, do this:
ibtnExpandResource.Attributes.Add("onclick","Javas cript:
OnPlusClick(this);")

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.parentElement.parentElement.rowIndex)
}
</script>
....
<asp:TemplateColumn>
<ItemTemplate>
<IMG src="../Images/Completed.gif" onclick="test(this)">
</ItemTemplate>
</asp:TemplateColumn>

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="ibtnExpandResource"
ImageUrl="../images/user.gif" onClick="javascript:
OnPlusClick(this);" style="cursor:hand;"></asp:Image>


In Page_Load, do this:
ibtnExpandResource.Attributes.Add("onclick","Javas cript:
OnPlusClick(this);")

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:TemplateColumn>
<ItemTemplate>
<asp:Image id="Image1" runat="server"
ImageUrl="../Images/Completed.gif"
onclick="test(this)"></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>

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.parentElement.parentElement.rowIndex)
}
</script>
...
<asp:TemplateColumn>
<ItemTemplate>
<IMG src="../Images/Completed.gif" onclick="test(this)">
</ItemTemplate>
</asp:TemplateColumn>

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="ibtnExpandResource"
ImageUrl="../images/user.gif" onClick="javascript:
OnPlusClick(this);" style="cursor:hand;"></asp:Image>

In Page_Load, do this:
ibtnExpandResource.Attributes.Add("onclick","Javas cript:
OnPlusClick(this);")

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
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...
0
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...
8
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...
17
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...
2
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...
3
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...
0
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...
2
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...
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...
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...
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
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,...
0
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.