Delegating control's event to the owner page

  1. #1

    Delegating control's event to the owner page

    Hello,

    I saw similar posts but although they're marked solved it doesn't work for me.

    Owner Page Code:
            protected void ShowWindowsEditor(object sender, AjaxEventArgs e)
            {
                string id = e.ExtraParams["taskId"];
                List<TwoGridsEntity> activities = DataActivity.GetTwoGridsList(id);
                TwoGrids1.SaveButtonClick += OnProcessClick;
                TwoGrids1.FillGrids(activities);
                TwoGrids1.Show();
            }
    
            protected void OnProcessClick(object sender, AjaxEventArgs e)
            {
                TwoGrids1.Hide();
            }
    Control Code
            public event ComponentAjaxEvent.AjaxEventHandler SaveButtonClick
            {
                add { Button5.AjaxEvents.Click.Event += value; }
                remove { Button5.AjaxEvents.Click.Event -= value; }
            }
    When I hit the save button in the control it doesn't fire the event, I attached in the owner page. What am I doing wrong or is this a bug?

    Hope to hear from you soon.

    Regards,
    Gokce


  2. #2

    RE: Delegating control's event to the owner page

    Hello,

    i tried attaching in aspx file directly which normally works fine with asp.net button control and also in the function and it didn't work in both cases. i put it in page_load and now it works.

            protected void Page_Load(object sender, EventArgs e)
            {
                TwoGrids1.SaveButtonClick += OnProcessClick;
            }
    What is the logic behind it?

    Thanks,
    Gokce
  3. #3

    RE: Delegating control's event to the owner page

    Hi*Gokce,

    Looks like setting the event handler during an AjaxEvent may not be working. I will investigate.*


    Geoffrey McGill
    Founder
  4. #4

    RE: Delegating control's event to the owner page

    Hi,

    Please note that AjaxEvent handler doesn't saverd in ViewState therefore if you set handler dynamically in codebehind then you need set this handler in each request for correct event handling. The last point where it is available (set handler) is page load event




  5. #5

    RE: Delegating control's event to the owner page

    Hello,

    I didn't only add it in the Ajax Event but also in the aspx page. The code which didn't work is below:

    <tar:TwoGrids ID="TwoGrids1" runat="server" SaveButtonClick = "OnProcessClick" />
    This time I was lucky that I don't need to change the event but otherwise it's impossible to do that. I want to learn how you would do it if you needed to change the function of event?

    Cheers,
    Gokce

Similar Threads

  1. Replies: 7
    Last Post: Jan 29, 2013, 11:59 AM
  2. Replies: 1
    Last Post: Jan 19, 2012, 4:20 PM
  3. using my owner css on Ext.net Controls
    By Egale in forum 1.x Help
    Replies: 14
    Last Post: Jul 12, 2011, 10:18 AM
  4. Replies: 2
    Last Post: Aug 27, 2009, 8:12 AM
  5. Replies: 5
    Last Post: Aug 04, 2009, 10:49 AM

Posting Permissions