B
Boricua
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)=='function'){ ")
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.GetPostBackEventReference(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
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)=='function'){ ")
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.GetPostBackEventReference(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