The control that triggered the UpdatePanel controls to refresh

Discussion in 'ASP .Net' started by Kika, Jan 17, 2008.

  1. Kika

    Kika Guest

    Hi All,
    On my page, I have a custom control in which asp server controls can be
    added and a UpdatePanel to notify the server of any edit in progress in the
    custom control...I would like to know which server control triggered the
    postback whitin my custom control. Currently, my customControl is declared as
    follow:
    <daf:UpdateInProgressPanel ID="UpdateInProgressPanel1"
    runat="server" DisabledStateControlId="Button1"
    OnUpdateOccured="UpdateInProgressPanel1_UpdateOccured">

    and the following events will trigger a postback:

    document.onchange = handleEvent;
    interceptor.onclick = handleEvent;
    interceptor.onkeypress = handleEvent;
    interceptor.onkeydown = handleEvent;
    interceptor.onpaste = handleEvent;

    My problem is that after postback, I would like to set the focus on the
    control which triggered the post back. So far, I have used the following:
    string ctrlname = page.Request.Params.Get("__EVENTTARGET");
    and
    if
    (((ScriptManager)this.Page.FindControl("ScriptManager1")).IsInAsyncPostBack)
    fromWhere =
    this.Page.Request[((ScriptManager)this.Page.FindControl("ScriptManager1")).ID];
    in order to get the control but i am always getting the custom control. I
    want to associated postback events to the custom control only but would like
    to know which control within it originated the postback...

    Any help will be appreciated.

    Thanks,
    Kika
    Kika, Jan 17, 2008
    #1
    1. Advertising

  2. Kika

    younlaot Guest

    On Jan 17, 12:09 pm, Kika <> wrote:
    > Hi All,
    > On my page, I have a custom control in which asp server controls can be
    > added and a UpdatePanel to notify the server of any edit in progress in the
    > custom control...I would like to know which server control triggered the
    > postback whitin my custom control. Currently, my customControl is declared as
    > follow:
    > <daf:UpdateInProgressPanel ID="UpdateInProgressPanel1"
    > runat="server" DisabledStateControlId="Button1"
    > OnUpdateOccured="UpdateInProgressPanel1_UpdateOccured">
    >
    > and the following events will trigger a postback:
    >
    > document.onchange = handleEvent;
    > interceptor.onclick = handleEvent;
    > interceptor.onkeypress = handleEvent;
    > interceptor.onkeydown = handleEvent;
    > interceptor.onpaste = handleEvent;
    >
    > My problem is that after postback, I would like to set the focus on the
    > control which triggered the post back. So far, I have used the following:
    > string ctrlname = page.Request.Params.Get("__EVENTTARGET");
    > and
    > if
    > (((ScriptManager)this.Page.FindControl("ScriptManager1")).IsInAsyncPostBack)
    > fromWhere =
    > this.Page.Request[((ScriptManager)this.Page.FindControl("ScriptManager1")).ID];
    > in order to get the control but i am always getting the custom control. I
    > want to associated postback events to the custom control only but would like
    > to know which control within it originated the postback...
    >
    > Any help will be appreciated.
    >
    > Thanks,
    > Kika


    You should open up your custom control as open source so I can take a
    gander. I've always wanted a control like what you have created. :)
    younlaot, Jan 17, 2008
    #2
    1. Advertising

  3. Kika

    bruce barker Guest

    in client script register a BeginRequestHandler and write the control id to a
    hidden field.

    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(
    function(sender, args)
    {
    $get('myHiddenCtl').value = args.get_postBackElement();
    });


    -- bruce (sqlwork.com)


    "Kika" wrote:

    > Hi All,
    > On my page, I have a custom control in which asp server controls can be
    > added and a UpdatePanel to notify the server of any edit in progress in the
    > custom control...I would like to know which server control triggered the
    > postback whitin my custom control. Currently, my customControl is declared as
    > follow:
    > <daf:UpdateInProgressPanel ID="UpdateInProgressPanel1"
    > runat="server" DisabledStateControlId="Button1"
    > OnUpdateOccured="UpdateInProgressPanel1_UpdateOccured">
    >
    > and the following events will trigger a postback:
    >
    > document.onchange = handleEvent;
    > interceptor.onclick = handleEvent;
    > interceptor.onkeypress = handleEvent;
    > interceptor.onkeydown = handleEvent;
    > interceptor.onpaste = handleEvent;
    >
    > My problem is that after postback, I would like to set the focus on the
    > control which triggered the post back. So far, I have used the following:
    > string ctrlname = page.Request.Params.Get("__EVENTTARGET");
    > and
    > if
    > (((ScriptManager)this.Page.FindControl("ScriptManager1")).IsInAsyncPostBack)
    > fromWhere =
    > this.Page.Request[((ScriptManager)this.Page.FindControl("ScriptManager1")).ID];
    > in order to get the control but i am always getting the custom control. I
    > want to associated postback events to the custom control only but would like
    > to know which control within it originated the postback...
    >
    > Any help will be appreciated.
    >
    > Thanks,
    > Kika
    bruce barker, Jan 17, 2008
    #3
    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. Replies:
    3
    Views:
    471
    Rob Meade
    Aug 8, 2007
  2. Nathan Sokalski
    Replies:
    1
    Views:
    287
    bruce barker
    Feb 27, 2008
  3. Nathan Sokalski
    Replies:
    1
    Views:
    570
    miher
    Jun 15, 2009
  4. Kika
    Replies:
    0
    Views:
    126
  5. Nathan Sokalski

    Handling events triggered by dynamically created controls

    Nathan Sokalski, Feb 27, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    116
    bruce barker
    Feb 27, 2008
Loading...

Share This Page