Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting RadioButton being checked

Status
Not open for further replies.

RebLazer

Programmer
Jun 7, 2002
438
US
When I try this:

Sub Page_Load(Sender As Object, E As EventArgs)

If (Object.ReferenceEquals(Sender, geog_all)) Then
trace.warn("USER CLICKED geog_all BUTTON - don't hide DataGrid1")
end if

...


The compiler complains:
Compiler Error Message: BC32022: 'Public Event CheckedChanged(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.


What I am trying to do is execute that IF block whenever radiobutton "geog_all" is checked and, thereby, does an autopostback which fires page_load.

What's the right way to do this, please?

Please help!
Thanks,
RebLazer
 
OOPS - that code was supposed to read:

Sub Page_Load(Sender As Object, E As EventArgs)

If (Object.ReferenceEquals(Sender, geog_all.checkedChanged)) Then
trace.warn("USER CLICKED geog_all BUTTON - don't hide DataGrid1")
end if

...

Thanks!

 
I'm not doing very well here... That code in the previous post is what is not correct. It (i.e. with the red text) is what is causing that compiler error (in the first post of this thread).

Sorry for the confusion - PLEASE HELP!!!

Thanks!
RebLazer
 
I may be missing your point here, but a radio button has a .checked property, which is what it sounds like you are after:

if geog_all.checked then
'the radio button was checked
else
'it wasn't checked
end if
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Link9,

Thanks for your reply.

Let me clarify.

My page looks like this: I've got three radiobuttons (all in the same group) that are autopostback=true. I have other things on the page that *also* cause a postback. I am trying to distinguish which one caused the postback. It is possible to have "geog_all" checked, without it being the cause of the post back - something else on the page may be the cause. So ".checked=true/false" won't do it. I need to be able to tell what triggered page_load to be called.

Thanks again!
RebLazer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top