I have a radio button that is declared in the .vb file. I need to connect it to an on_click subroutine.
On the .aspx page, i would do:
.....onclick ="My_ClickFunction" ...
How can I do this from the .vb file?Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
is there a way to do this dynamically? I'm going to generate x number of radiobuttons, and
i want them all to use this same subroutine.
also, is there a way to find information about the button that was clicked inside of the
subroutine? is it sender.value?
for each blah in ack
create a new button
button.value = a unique number
somehow, link this button to the same sub
End for...
Sub mySub (ByVal sender As System.Object, ByVal e As System.EventArgs)
Take the unique number of the button that was clicked, and do something with it.
End Sub
Why not use a RadioButtonList. That way all of the radio buttons automatically use the same event handler. Check out the QuickStart tutorials here:
http://www.dotnetjunkies.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/radiobuttonlist/doc_radiolist.aspx
i don't think a radiobutton list will work for me. In a radiobutton list, if you
press on one, all the rest of them get unselected. I only want some of them
to get unselected.
I'm trying to do something similar to what they have at:
http://lundandlund.net/cgi-bin/inoutPRO/inoutPRO.pl
they have about x rows with 2 radiobuttons on each row.
so it's kinda like in each row, they have a separate radiobutton list.
Because I don't know what x equals until after I check the my database,
I can't hardwire them into my .aspx file. I think I have to do some sort of a
FOR loop to create them separately, then wire them up.
each radiobutton will have a different value = "?",
and I'm going to have to do something different for each button, depending
on what the value is.
can i do something like sender.value to get the value of the button pressed?
you still would be better off using a radiobuttonlist, but have one radiobuttonlist per row. You aren't doing something crazy on top of this, like having a datagrid spit this out are you?
I was going to use a System.Web.UI.WebControls.Table
and add the radiobuttons into
System.Web.UI.WebControls.cell
add the cells to
System.Web.UI.WebControls.row
then add the rows to
System.Web.UI.WebControls.Table
is there a better way to do this?
also, in "sender as object, e as eventargs"
what is "sender"? does it refer to the button that was pressed?
can i do sender.enabled = false?
That's how I would do it
sender is a reference to the object that called it, you can cast it into a specific control if you'd like. I've never really used it that much. How I understand it, it is not passing the whole object, just a reference to that object in memory, so you don't have to worry about it slowing down your code as that is very small.
0 comments:
Post a Comment