webnoob
webnoob

Reputation: 15934

Button not processing onClick method

I have a button on an ascx control that calls a method on the onClick event:

<asp:Button id="bUpdateText" onClick="FUpdate" ValidationGroup="Update" CausesValidation="False" Text="Update" cssclass="button" runat="server" />

Normally I use this control on it's own page and the button works. This time round however, I am loading this control into a Div that is present on the home page of my site (that way I can show the contents with a little bit of JQuery). However, when I bring the control in this way, the onClick event doesn't fire and I am not sure what could cause that.

Sorry I don't have any code sample but the nature of the site makes it difficult to provide any that would make sense.

In short, what would stop this event firing now?

p.s I have tried adding validation groups to all other buttons and validation controls on the page and there is only ONE form present on the page.

EDIT: I have only just added the validation stuff in to see if that does anything. By default it has been like this and still didn't work:

<asp:Button id="bUpdateText" onClick="FUpdate" Text="Update" cssclass="button" runat="server" />

As mentioned as well, this works when I use this control on it's own page (loaded directly into Default.aspx) so I don't think the case of onClick matters.

EDIT2: I have just noticed that when I click this button, other validation controls on my page are being triggered even though they have their own DIFFERENT validation group?! Taking these controls out doesn't help though.

Thanks.

Upvotes: 0

Views: 763

Answers (3)

webnoob
webnoob

Reputation: 15934

I have found out what is causing the issue.

This control that I am now including is called on the Page_Finalize() and I am guessing that by this point the viewstate has forgotten it needs to do anything. Loading this control on the page load sorts it out.

Thanks for looking.

Upvotes: 1

maycil
maycil

Reputation: 764

You can use Firebug to see what happen in Update validationGroup. it looks like your page execute only client-side button click because of Update validationGroup.

Upvotes: 0

guildsbounty
guildsbounty

Reputation: 3361

To start, if you set the 'causesValidation' property to false, you do not need a validation group. Additionally, I believe that ASP cares about case when dealing with the OnClick command.

i.e. it should be OnClick not onClick

Yeah, annoying and small, but that might be your problem

Upvotes: 0

Related Questions