Checkbox Event Firing

J

Jack Turnbull

Hi,
I have a Checkbox in a Repeater set to AutoPostBack = true. I have pointed
OnCheckedChanged to a Sub but it doesn't fire. If I move the checkbox out of
the Repeater it fires! Any ideas?
Thanks
 
A

Anachostic

Nested controls usually don't raise their own events. I can think of a
couple of ways to handle this: neither is elegant, only one I have done
myself.

The one I have done is to put a hidden button (visible=false) on the page
and use Javascript on the checkbox to trigger a postback as if the hidden
control had been clicked. If you need to access the specific line that
had the checkbox clicked, I would put a button inside the ItemTemplate so
that you could respond to the repeater.ItemCommand event and get the line
item. Otherwise, you can put the button outside the repeater and trigger
it.

The other way I could think of is to loop though the repeater during
postback and find out if the checkbox has changed. Not very efficient at
all. You may want that for some very odd reason.

Heres a quick code snip:

<FooterTemplate>
<input type="checkbox" ID="cmdTriggerDelete" value="Delete"
OnClick="__doPostBack('cmdDelete','click');" />
</FooterTemplate>
</asp:Repeater>

<asp:Button Runat=server ID="cmdDelete" Visible=false />
 
J

Jack Turnbull

Thanks Guys,
I'll take the solution to wire a hidden button - I already have a button in
each row, I'll just hide it. The idea was to get rid of it to prevent the
user getting miffed at no update on clicking the button on a different row
to the checkbox change.
Thanks & Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top