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: Multiple controls raise the same event.

How: Multiple controls raise the same event.

Scheduled Pinned Locked Moved ASP.NET
csharphelpquestionasp-netwinforms
3 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.
  • D Offline
    D Offline
    DotNet_Newbie
    wrote on last edited by
    #1

    Hello all, I writing several user controls for a ASP.NET in C#. I want to get all the controls to be able to raise the same event, how can I do that? More info: The problem I’m facing is: I defined the delegate under the name space so it can be seen from any class, but the events are defined within the class scope. Now the problem is when the user control tries to raise the event, I found that the event is null (it hasn’t been constructed). Any help is highly appreciated Thanks

    P 1 Reply Last reply
    0
    • D DotNet_Newbie

      Hello all, I writing several user controls for a ASP.NET in C#. I want to get all the controls to be able to raise the same event, how can I do that? More info: The problem I’m facing is: I defined the delegate under the name space so it can be seen from any class, but the events are defined within the class scope. Now the problem is when the user control tries to raise the event, I found that the event is null (it hasn’t been constructed). Any help is highly appreciated Thanks

      P Offline
      P Offline
      Paul Riley
      wrote on last edited by
      #2

      An event will be null until you attach a method to it from the page with MyControl.MyEvent += new MyEventHandler(MyMethod). Thus when you call an event, you should always check that it isn't null first. Is that your problem or am I missing the point? Paul

      V 1 Reply Last reply
      0
      • P Paul Riley

        An event will be null until you attach a method to it from the page with MyControl.MyEvent += new MyEventHandler(MyMethod). Thus when you call an event, you should always check that it isn't null first. Is that your problem or am I missing the point? Paul

        V Offline
        V Offline
        VC Sekhar Parepalli
        wrote on last edited by
        #3

        Yup, This helped me. Thanks Paul!

        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