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. events of usercontrol

events of usercontrol

Scheduled Pinned Locked Moved ASP.NET
question
4 Posts 3 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.
  • I Offline
    I Offline
    israeli
    wrote on last edited by
    #1

    Hi everybody, How do I handle the events of my user control (*.ascx) from the containing page (*.aspx.cs )? Thank you

    C 1 Reply Last reply
    0
    • I israeli

      Hi everybody, How do I handle the events of my user control (*.ascx) from the containing page (*.aspx.cs )? Thank you

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The easy way is to make the items that fire events public, but the good way is to expose the events in the control, and subscribe to them in the containing page. Christian Graus - Microsoft MVP - C++

      A 1 Reply Last reply
      0
      • C Christian Graus

        The easy way is to make the items that fire events public, but the good way is to expose the events in the control, and subscribe to them in the containing page. Christian Graus - Microsoft MVP - C++

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Hi Christian, Can you illustrate me how to expose an event ? Thanks

        C 1 Reply Last reply
        0
        • A Anonymous

          Hi Christian, Can you illustrate me how to expose an event ? Thanks

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          In the control public delegate void ClickEvent(); public ClickEvent OnClick = null; private void click_button(object sender, EventArgs ea) { if (OnClick!=null) OnClick(); } in the page in page load : myControl.OnClick += new myControl.ClickEvent(this.ControlClick); then: private void ControlClick() { } You can add arguments to the delegate if you'd like, or just expose an EventHandler ( from memory ), which means it has the same args as the event in the first place. Christian Graus - Microsoft MVP - C++

          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