[Events] Problems...

Discussion in 'ASP .Net Building Controls' started by Lupin_3d, Jul 8, 2003.

  1. Lupin_3d

    Lupin_3d Guest

    Hi...
    i have an aspx page(home.aspx) that contains an ascx usercontrol
    (chrt.ascx).
    In home.aspx there is a button with his event...
    In the ascx page i want to create an event for that button.... i do in
    this way...

    (home.aspx)
    private void InitializeComponent()
    {
    this.button1.click += new System.EventHandler(this.button1_Click);
    }

    public static event EventHandler butt_click;

    private void button1_Click(object sender, System.EventArgs e)
    {
    butt_click(this,e);
    }

    (chrt.ascx)
    private void InitializeComponent()
    {
    home.butt_click += new System.EventHandler(this.butt1_click);
    }

    private void butt1_click(object sender, System.EventArgs e)
    {
    ...... // code that calls a stored procedure
    }

    But....if i open Sql Profiler i see that when i click this button once
    the stored procedure is called once...if i click another time the
    stored procedure is called twice...and so on...after an intense use of
    the site (the button was clicked ten times) the site become very slow
    due the many calling to the stored procedure...

    can u help in my trouble?

    10nx a lot.
     
    Lupin_3d, Jul 8, 2003
    #1
    1. Advertising

  2. Lupin_3d

    Robozel Guest

    Hi, mitico Lupin,
    your problem stays into
    public static event EventHandler butt_click;
    you declared the event static, and so every time the control creates it
    subscribes again to the event
    home.butt_click += new System.EventHandler(this.butt1_click);
    remove the static from the butt_click desclaration.

    r.

    "Lupin_3d" <> wrote in message
    news:...
    > Hi...
    > i have an aspx page(home.aspx) that contains an ascx usercontrol
    > (chrt.ascx).
    > In home.aspx there is a button with his event...
    > In the ascx page i want to create an event for that button.... i do in
    > this way...
    >
    > (home.aspx)
    > private void InitializeComponent()
    > {
    > this.button1.click += new System.EventHandler(this.button1_Click);
    > }
    >
    > public static event EventHandler butt_click;
    >
    > private void button1_Click(object sender, System.EventArgs e)
    > {
    > butt_click(this,e);
    > }
    >
    > (chrt.ascx)
    > private void InitializeComponent()
    > {
    > home.butt_click += new System.EventHandler(this.butt1_click);
    > }
    >
    > private void butt1_click(object sender, System.EventArgs e)
    > {
    > ..... // code that calls a stored procedure
    > }
    >
    > But....if i open Sql Profiler i see that when i click this button once
    > the stored procedure is called once...if i click another time the
    > stored procedure is called twice...and so on...after an intense use of
    > the site (the button was clicked ten times) the site become very slow
    > due the many calling to the stored procedure...
    >
    > can u help in my trouble?
    >
    > 10nx a lot.
     
    Robozel, Jul 11, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shiv
    Replies:
    0
    Views:
    518
  2. Alvin Bruney
    Replies:
    1
    Views:
    749
  3. =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=

    order of events - dynamic checkbox events

    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Aug 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    600
    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
    Aug 17, 2005
  4. newbye
    Replies:
    0
    Views:
    593
    newbye
    Jul 6, 2006
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    424
    Chris
    Aug 30, 2005
Loading...

Share This Page