473,386 Members | 1,846 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,386 software developers and data experts.

Add onclick attribute to image button still puts javascript postback function

I'm using ASP.NET 2.0

I got an imagebutton at the end of my form as a submit button. When
the user clicks it the button becomes disabled and continues with the
postback.
This is what I got, ib is the imagebutton.
Dim sbValid As New StringBuilder()
sbValid.Append("if(typeof(Page_ClientValidate)=='f unction'){ ")
sbValid.Append("if (Page_ClientValidate() == false) { return
false; }} ")

sbValid.Append("this.disabled = true;")

Dim myPostBackOptions As New PostBackOptions(ib)
myPostBackOptions.PerformValidation = True
sbValid.Append(ClientScript.GetPostBackEventRefere nce(myPostBackOptions))
sbValid.Append(";")
'ib.Attributes.Add("onclick", sbValid.ToString())

ib.OnClientClick = sbValid.ToString()

This is my problem: This works fine in IE. Firefox on the other hand
I noticed that the button when click posted back twice. Looking at the
rendered source code I noticed that the postback function in the
onclick attribute of the image button is there twice. I presume that
ASP.NET is adding it to the end of my javascript. How to stop it from
doing this?

I went ahead and comment out the code that adds the postback function
(lines: 7-11). Worked fine in firefox but broke IE. I was thinking of
wrapping that code with an if statement (if browser = IE), but I am not
sure what happens if the browser is Opera, Safari or others so I
decided not to go that route.

So is there a way to tell asp.net not to add javascript postback
function to onclick attribute. That way i can just added myself.

Thank you

Rick

Nov 16 '06 #1
0 2662

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

Similar topics

2
by: Rob Manger | last post by:
Hi All, I am hoping someone can help me. I am trying to setup my main page so that when the user moves the mouse over an image, it changes the source (got this working). When the user CLICKS...
4
by: masantha wee | last post by:
Hi all, I am using Firefox and embedding Javascript in html. I understand that we can use mouse events by coding them in the body of html (by creating a button or anything and by adding in the...
2
by: Sedef | last post by:
Hi, i'm trying to create a custom Button user control which will be derived from System.Web.UI.WebControls.Button. the normal server side Button class creates some client side javascript code for...
5
by: moondaddy | last post by:
I have a <a> element in a datagrid which wraps some asp.net labels. this element also has an onclick event which does not fire in netscape 6 (and perhaps other browsers for all I know...). Below...
1
by: quickcur | last post by:
Hi, here is my code: <html> <head> <script type="text/javascript"> function setImage(num) { alert(num); }
4
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
1
by: zhengyan11 | last post by:
Hey, what I try to do is when a user clicked an image button on my site, I use onClick to trigger a dialog box and at the same time I use button.attach("onClick", savecookie) to mark this...
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.