CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Location
    Italy
    Posts
    90

    Problem with radio button event handler in WebForm

    Hi everyone, I've the following problem with a WebForm, in my application on Form PageLoad I've added some codelines in order to add a radio button inside a TableRow, all seems to works fine except eventhandler management, no event is fired when I click on radio button control
    Can someone suggest me a solution?
    Here you are my code

    Code:
        protected void Page_Load(object sender, EventArgs e)
        {
            TableRow oTabRow = new TableRow();
            TableCell oTabCell = new TableCell();
    
            RadioButton myCustRB = new RadioButton();
            myCustRB.ID = "Test";
            myCustRB.Text = "Test";
            myCustRB.CheckedChanged += new EventHandler(Clicked);
            oTabCell.Controls.Add(myCustRB);
            oTabRow.Controls.Add(oTabCell);
            Table1.Controls.Add(oTabRow);
    
        }
        public void Clicked(object sender, EventArgs e)
        {
            Response.Write("Clicked");
        }
    Last edited by PeejAvery; May 2nd, 2008 at 07:57 AM. Reason: Added code tags.

  2. #2
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

    Re: Problem with radio button event handler in WebForm

    1. Please use Code tags when you post code.
    2. Set AutoPostBack to true
    Code:
    myCustRB.AutoPostBack = true;
    Hesham A. Amin
    My blog , Articles


    <a rel=https://twitter.com/HeshamAmin" border="0" /> @HeshamAmin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured