Andy & Paul,
One problem : this won't work if you have any validators on the page. At
least, after hours of frustration I still can't make it work.
Part of the reason it took me so long to confirm this was that I couldn't
get it to work even if I commented out the validators! I used <!-- ... -->
still rendered, even after a fresh build.
If I completely deleted the validators from the .aspx page, the onclick
worked. I discovered this when I broke up the tag with spaces ( "as p:req
uiredfieldvalidator") to make sure it wasn't being read while commented out,
and I got complaints from the compiler in vs, so I deleted the line
altogether. Just that change made it work.
Am I missing something here? Is there anyway to add the onclick attribute
to an asp:button control and have it work, even when the validators are
present? I really miss being able to do this.
> Put this in your CodeBehind:
> cmdDeleteUser.Attributes.Add("onclick", "return(confirm('Are you sure you
> wish to delete this user?'))");
> This will add a client-side onclick attribute.
> > I have an <asp:button> called cmdDeleteUser which I use to delete user
> > records from a database. Ideally what I want to happen is for the
> > to delete this user?") and only trigger the server-side event
> > cmdDeleteUser_click if the user selects Yes.
> > Any ideas?