You need to wire the button to its event.
 
This is how its done:
 
      Dim btn As New Button
      btn.Text = "Submit"
btn.ID = "Submit";
btn.CommandName = "SubmitRadio"
btn.Command += new CommandEventHandler(SubmitRadio);
pnl1.Controls.Add(btn)


 
And now you change the function SubmitRadio() as follows:
 
SubmitRadio(object sender, CommandEventArgs e)
{
      //Here e.CommandName would give you the value "SubmitRadio";
      If you have more than one button but want to wire up to the same
event, you can do that too.
      You can use either the command name to differentiate which button
caused the event or you can use the ID of the button.
 
To get the id of the button or to get any property of the button, you
can do this:
Button btn = (Button) sender;
 
String id = btn.ID;
}
 
-----Original Message-----
From: Burak Gunay [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 29, 2004 10:10 AM
To: [EMAIL PROTECTED]
Subject: RE: [AspNetAnyQuestionIsOk] How do you access a dynamically
created control's values on the server side?
 

Hi Rajendra,

I created a radio button in page_load and it showed
up fine. 

But I don't know how to tie the CommandName property
of the button to the click event.

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    If Not Page.IsPostBack Then
        Dim pnl1 As New Panel
        pnl1.Visible = True
        Page.FindControl("Form1").Controls.Add(pnl1)

        Dim radio1 As New RadioButton
        radio1.ID = "radio1"
        radio1.Checked = False
        radio1.GroupName = "COS"
        radio1.Attributes.Add("onclick",
"javascript:toggle('YES','radGrantAllPermissions');")
        pnl1.Controls.Add(radio1)

        Dim btn As New Button
        btn.Text = "Submit"
        btn.CommandName = "SubmitRadio"
        pnl1.Controls.Add(btn)
    end if
End Sub

' this never gets called :(
Sub SubmitRadio()
        Response.Write("Hello")
End Sub

How can I get it to call SubmitRadio?

Thanks,

Burak



            
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com



Yahoo! Groups Sponsor
ADVERTISEMENT
click here
<http://us.ard.yahoo.com/SIG=129i6m0fs/M=295196.4901138.6071305.3001176/
D=groups/S=1705006764:HM/EXP=1096553409/A=2128215/R=0/SIG=10se96mf6/*htt
p:/companion.yahoo.com> 
 
<http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=group
s/S=:HM/A=2128215/rand=216836806> 
 
  _____  

Yahoo! Groups Links
*         To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
  
*         To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]
cribe> 
  
*         Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to