Event on Dynamic Control - ASP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?R2lkaQ==?=

    Event on Dynamic Control - ASP

    Hello,

    I've created a dynamic button and checkbox and i want to create an event for
    each one of them.
    altough i've created the event and assigned them to each control, nothing
    happens,
    the event is not occurring.
    What am i doing wrong?

    this is my code for the checkBox:
    CheckBox cb = new CheckBox();

    cb.Text = "Text";
    cb.Font.Bold = true;
    cb.ID = "Friend_cb" ;
    cb.Font.Name = "Tahoma";
    cb.Font.Size = new FontUnit("16pt" );
    cb.ForeColor = Color.Blue;
    cb.Checked = false;
    cb.CheckedChang ed += new System.EventHan dler(Show_OutSi de_TextBox);
    cb.EnableViewSt ate = true;
    this.form1.Cont rols.Add(cb);

    private void Show_OutSide_Te xtBox(object sender, System.EventArg s e)
    {
    if (((CheckBox)sen der).Checked == true)
    {
    Create_Label(0, "<br><br>") ;
    Create_OutSide_ Player_TextBox( );
    }
    }

    Thanks,
    Gidi
  • =?Utf-8?B?TWFuaXNoIEJhZm5h?=

    #2
    RE: Event on Dynamic Control - ASP

    Hi,
    As far as my understanding goes if you are creating dynamic controls then
    you need to recreate same controls on postback and also give them same ID as
    previously given before postback
    --
    Hope this helps.
    Thanks and Regards.
    Manish Bafna.
    MCP and MCTS.



    "Gidi" wrote:
    Hello,
    >
    I've created a dynamic button and checkbox and i want to create an event for
    each one of them.
    altough i've created the event and assigned them to each control, nothing
    happens,
    the event is not occurring.
    What am i doing wrong?
    >
    this is my code for the checkBox:
    CheckBox cb = new CheckBox();
    >
    cb.Text = "Text";
    cb.Font.Bold = true;
    cb.ID = "Friend_cb" ;
    cb.Font.Name = "Tahoma";
    cb.Font.Size = new FontUnit("16pt" );
    cb.ForeColor = Color.Blue;
    cb.Checked = false;
    cb.CheckedChang ed += new System.EventHan dler(Show_OutSi de_TextBox);
    cb.EnableViewSt ate = true;
    this.form1.Cont rols.Add(cb);
    >
    private void Show_OutSide_Te xtBox(object sender, System.EventArg s e)
    {
    if (((CheckBox)sen der).Checked == true)
    {
    Create_Label(0, "<br><br>") ;
    Create_OutSide_ Player_TextBox( );
    }
    }
    >
    Thanks,
    Gidi

    Comment

    • =?Utf-8?B?R2lkaQ==?=

      #3
      RE: Event on Dynamic Control - ASP

      Hi,
      Thanks For the quick reply.

      I tried to add the folowing code to my Page_Load()
      if (this.IsPostBac k)
      {
      Create_OutSide_ Player_CheckBox ();
      return;
      }

      and still nothing happens.

      "Manish Bafna" wrote:
      Hi,
      As far as my understanding goes if you are creating dynamic controls then
      you need to recreate same controls on postback and also give them same ID as
      previously given before postback
      --
      Hope this helps.
      Thanks and Regards.
      Manish Bafna.
      MCP and MCTS.
      >
      >
      >
      "Gidi" wrote:
      >
      Hello,

      I've created a dynamic button and checkbox and i want to create an event for
      each one of them.
      altough i've created the event and assigned them to each control, nothing
      happens,
      the event is not occurring.
      What am i doing wrong?

      this is my code for the checkBox:
      CheckBox cb = new CheckBox();

      cb.Text = "Text";
      cb.Font.Bold = true;
      cb.ID = "Friend_cb" ;
      cb.Font.Name = "Tahoma";
      cb.Font.Size = new FontUnit("16pt" );
      cb.ForeColor = Color.Blue;
      cb.Checked = false;
      cb.CheckedChang ed += new System.EventHan dler(Show_OutSi de_TextBox);
      cb.EnableViewSt ate = true;
      this.form1.Cont rols.Add(cb);

      private void Show_OutSide_Te xtBox(object sender, System.EventArg s e)
      {
      if (((CheckBox)sen der).Checked == true)
      {
      Create_Label(0, "<br><br>") ;
      Create_OutSide_ Player_TextBox( );
      }
      }

      Thanks,
      Gidi

      Comment

      • olduncleamos

        #4
        Re: Event on Dynamic Control - ASP

        On Sep 17, 6:06 am, Gidi <shna...@hotmai l.com.dontspamw rote:
        I tried to add the folowing code to my Page_Load()
        if (this.IsPostBac k)
        {
        Create_OutSide_ Player_CheckBox ();
        return;
        }
        >
        and still nothing happens.
        >
        >
        Page_Load is too late. You should do that in Init.


        Comment

        Working...