Groups | Blog | Home
all groups > asp.net webcontrols > january 2004 >

asp.net webcontrols : button control and cancel submit


jbhopper
1/27/2004 11:51:08 AM
I use Attribute.Add to call a javascript function client-side from an asp:button control. The javascript function opens a window. My problem is that the submit event fires after the javascript code executes. When I view the source in "running documents" I see that the button is declared as "type=submit", even when I provide a commandName, which I thought changed a submit button into a command button. When I try to return false from the javascript function I get "return type mismatch". I've used this method successfully in user controls, but now I can't use it in a web page. Any suggestions

Ken Cox [Microsoft MVP]
1/28/2004 10:23:21 PM
Are you putting return false in your javascript or in the click event? Try
it this way?

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Button1.Attributes.Add("onclick", _
"doWelcome(); return false;")
End Sub

If this isn't the issue, maybe you could post the code that isn't working
and we can try again?

Ken
MVP [ASP.NET]

[quoted text, click to view]
AddThis Social Bookmark Button