Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to add control at run time and handle it

How to add control at run time and handle it

Scheduled Pinned Locked Moved ASP.NET
comhelptutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sujit Gupta
    wrote on last edited by
    #1

    i have problem, I want to add control at runtime like two checkBox . when i checked first then enable false of second checkedbox. if any friend have answer then send me mail or post message. Thanks sujitvns4u@gmail.com

    Sujit

    I 1 Reply Last reply
    0
    • S Sujit Gupta

      i have problem, I want to add control at runtime like two checkBox . when i checked first then enable false of second checkedbox. if any friend have answer then send me mail or post message. Thanks sujitvns4u@gmail.com

      Sujit

      I Offline
      I Offline
      il_masacratore
      wrote on last edited by
      #2

      Hi, Add the controns in design view and hide the second. On the firsts, activate the AutoPostBack property and on the Page_Load change the visibility of the second checking the checked value of the first.

      S S 2 Replies Last reply
      0
      • I il_masacratore

        Hi, Add the controns in design view and hide the second. On the firsts, activate the AutoPostBack property and on the Page_Load change the visibility of the second checking the checked value of the first.

        S Offline
        S Offline
        shabonaa
        wrote on last edited by
        #3

        i think he meaned to create the controls at run time on demand.

        1 Reply Last reply
        0
        • I il_masacratore

          Hi, Add the controns in design view and hide the second. On the firsts, activate the AutoPostBack property and on the Page_Load change the visibility of the second checking the checked value of the first.

          S Offline
          S Offline
          Sujit Gupta
          wrote on last edited by
          #4

          Dear friend my question was that i'm adding control at run time not design time then how to handle event of this control. Thanks for reply

          Sujit

          A 1 Reply Last reply
          0
          • S Sujit Gupta

            Dear friend my question was that i'm adding control at run time not design time then how to handle event of this control. Thanks for reply

            Sujit

            A Offline
            A Offline
            Arun Immanuel
            wrote on last edited by
            #5

            Check this out and please reply me.... public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { CheckBox c1 = new CheckBox(); CheckBox c2 = new CheckBox(); c1.ID = "C1"; c2.ID = "C2"; c1.AutoPostBack = true; c2.AutoPostBack = true; Page.Form.Controls.Add(c1); //or Panel1.Controls.Add(c1); Page.Form.Controls.Add(c2); //or Panel1.Controls.Add(c2); c1.CheckedChanged += new EventHandler(c1_CheckedChanged); } private void c1_CheckedChanged(object sender, EventArgs e) { if (((CheckBox)Page.Form.FindControl("C1")).Checked) //Or Panel1.FindControl("C1") { ((CheckBox)Page.Form.FindControl("C2")).Enabled = false; } else { ((CheckBox)Page.Form.FindControl("C2")).Enabled = true ; } } }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups