My page is not triggering the RaisePostBackEvent() method

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Oct 11, 2007.

  1. In my *.aspx.vb file, I override the RaisePostBackEvent() method so that I
    can run code during any postback. I know that a postback is occurring
    because IsPostBack() returns True, but none of the code in the following is
    executed:

    Protected Overrides Sub RaisePostBackEvent(ByVal sourceControl As
    System.Web.UI.IPostBackEventHandler, ByVal eventArgument As String)
    Dim outputwriter As System.IO.StreamWriter =
    System.IO.File.AppendText(Server.MapPath("debugging.txt"))
    outputwriter.WriteLine(String.Format("eventArgument={0}; Time={1}",
    eventArgument, Date.Now.ToLongTimeString()))
    outputwriter.Close()
    MyBase.RaisePostBackEvent(sourceControl, eventArgument)
    End Sub

    Am I doing something wrong here? Is there something else I must do in order
    to use the the RaisePostBackEvent() method? Any help would be appreciated.
    Thanks.
    Nathan Sokalski, Oct 11, 2007
    #1
    1. Advertising

  2. Nathan Sokalski

    bruce barker Guest

    the RaisePostBackEvent is only called if the control is the one that
    caused the postback. its generally used to raise the server OnClick event.

    -- bruce (sqlwork.com)

    Nathan Sokalski wrote:
    > In my *.aspx.vb file, I override the RaisePostBackEvent() method so that
    > I can run code during any postback. I know that a postback is occurring
    > because IsPostBack() returns True, but none of the code in the following
    > is executed:
    >
    > Protected Overrides Sub RaisePostBackEvent(ByVal sourceControl As
    > System.Web.UI.IPostBackEventHandler, ByVal eventArgument As String)
    > Dim outputwriter As System.IO.StreamWriter =
    > System.IO.File.AppendText(Server.MapPath("debugging.txt"))
    > outputwriter.WriteLine(String.Format("eventArgument={0};
    > Time={1}", eventArgument, Date.Now.ToLongTimeString()))
    > outputwriter.Close()
    > MyBase.RaisePostBackEvent(sourceControl, eventArgument)
    > End Sub
    >
    > Am I doing something wrong here? Is there something else I must do in
    > order to use the the RaisePostBackEvent() method? Any help would be
    > appreciated. Thanks.
    bruce barker, Oct 11, 2007
    #2
    1. Advertising

  3. Nathan Sokalski

    IfThenElse Guest

    See
    http://www.velocityreviews.com/forums/t75668-raisepostbackevent-question.html
    and

    http://dotnetjunkies.com/WebLog/willemo/archive/2005/02/23/56278.aspx

    From link above.
    "
    I enjoy writing web controls. However, the last couple of days I've been
    having a lot of trouble with RaisePostBackEvent. Sometimes, no matter how
    hard I try, I just can't get RaisePostBackEvent to fire unless I call
    Page.RegisterRequiresRaiseEvent(this) in LoadPostData.

    Other times my eventArgument parameter in RaisePostBackEvent is null. Even
    if it has been specified and looks perfect in HTML. I've then had to resort
    to funny code (that checks __EVENTTARGET and __EVENTARGUMENT) to get around
    it.

    When I have to hack to get something working I'm almost 100% sure that I'm
    doing something wrong somewhere. But with this I am really stumped. Maybe my
    computer needs a new install.

    Update: Problem solved! Page.RegisterRequiresRaiseEvent(this) in
    LoadPostData was a very wrong way to solve the problem.

    The reason RaisePostBackEvent was not being called was simple - the
    framework will only call RaisePostBackEvent on one control. In my case the
    wrong control's RaisePostBackEvent was being called. In another custom
    control I declared a hidden <input> tag with name set to the UniqueID. This
    is usually the way I go about creating a control that implements
    IPostBackDataHandler. The framework was getting confused and called
    RaisePostBackEvent in the wrong control (even though __EVENTTARGET pointed
    to the correct control).

    In this case, the other control did not implement IPostBackDataHandler and
    shouldn't have included the hidden <input>."





    "Nathan Sokalski" <> wrote in message
    news:...
    > In my *.aspx.vb file, I override the RaisePostBackEvent() method so that I
    > can run code during any postback. I know that a postback is occurring
    > because IsPostBack() returns True, but none of the code in the following
    > is executed:
    >
    > Protected Overrides Sub RaisePostBackEvent(ByVal sourceControl As
    > System.Web.UI.IPostBackEventHandler, ByVal eventArgument As String)
    > Dim outputwriter As System.IO.StreamWriter =
    > System.IO.File.AppendText(Server.MapPath("debugging.txt"))
    > outputwriter.WriteLine(String.Format("eventArgument={0}; Time={1}",
    > eventArgument, Date.Now.ToLongTimeString()))
    > outputwriter.Close()
    > MyBase.RaisePostBackEvent(sourceControl, eventArgument)
    > End Sub
    >
    > Am I doing something wrong here? Is there something else I must do in
    > order to use the the RaisePostBackEvent() method? Any help would be
    > appreciated. Thanks.
    IfThenElse, Oct 11, 2007
    #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. Lucas Tam
    Replies:
    0
    Views:
    416
    Lucas Tam
    Aug 19, 2003
  2. Karl Hungus

    RaisePostBackEvent question

    Karl Hungus, Apr 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,324
    Teemu Keiski
    Apr 12, 2004
  3. =?Utf-8?B?U3RldmUgR3VpZG9z?=

    RaisePostBackEvent Not Firing

    =?Utf-8?B?U3RldmUgR3VpZG9z?=, Apr 6, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,608
    =?Utf-8?B?U3RldmUgR3VpZG9z?=
    Apr 7, 2005
  4. Nathan Sokalski
    Replies:
    2
    Views:
    1,030
    IfThenElse
    Oct 11, 2007
  5. Cristian Serban

    RaisePostBackEvent not raised

    Cristian Serban, Feb 23, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    188
    Cristian Serban
    Feb 27, 2004
Loading...

Share This Page