this is the __doPostBack function which is called by any of our controls that postback. What it does is it takes an eventTarget(the control ID that is postback) and an eventArgument(this is extra info you might want to pass along with the event) and sets these values into the hiddenfields before causing the form to submit. This is how your webform knows who postback etc. You can call this funtion from any clientside code you might have and pass it an id. Please note however that this script is injected into the page only when there is a control on your webform that postsback, so for you to be able to call this function from your clientside code you need to have atleast one control on your webform that postsback. otherwise you would be calling _doPostBack but the function is never there coz it was never injected into your page. "Fabrizio" wrote in message news:5EF98373-1AD8-4DD9-B580-33965F122D33@microsoft.com...[quote] > Eh, sorry for being not so clear. > Thinking about it i can set the question in a much simple way (the code i[/quote] could show would not clear the nature of the problem, it's all in my mind :)).[quote] > Being in the Page_Load of a WebForm how can i know if an event is going to[/quote] fire ? a button_click, a grid_itemcommand, and so on.[quote] > Can i see also events fired in a user control in the web form ? > Can i see the event also in the page load of the user control ? > And a last question connected, how do i call a __PostBack from javascript[/quote] in the correct manner ?[quote] > > P.S. Speaking about my problem i found really good use of the[/quote] Page_PreRender event, but i would still like to know if i can get this information.[quote] > > I hope i've been clear, instead i'll try to be more. > Thanks, > Fabrizio[/quote] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => <5EF98373-1AD8-4DD9-B580-33965F122D33@microsoft.com> [htmlstate] => on_nl2br [postusername] => Alessandro Zifiglio [ip] => alessandrozifig [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 5 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Know in user control page_load if an user control event is going to be fired - ASP.NET Building Controls

Know in user control page_load if an user control event is going to be fired - ASP.NET Building Controls

Hi all, i have built a user control that shows a map and let the user zoom in, out, usual stuff. Putting this object in a webform the user can cause page postback without touching the user control, so in user control page_load i check if not ib_MapLoaded then LoadMap Unluckily with this logic if the user ask for a ZoomIn the ZoomIn_Click is fired after the user control page_load and i load the map twice for every event. Is there a way to know in user control page_load if other event of the user control are pending ? Or ...

  1. #1

    Default Know in user control page_load if an user control event is going to be fired

    Hi all,
    i have built a user control that shows a map and let the user zoom in, out, usual stuff.
    Putting this object in a webform the user can cause page postback without touching the user control, so in user control page_load i check
    if not ib_MapLoaded then LoadMap

    Unluckily with this logic if the user ask for a ZoomIn the ZoomIn_Click is fired after the user control page_load and i load the map twice for every event.
    Is there a way to know in user control page_load if other event of the user control are pending ? Or a tip to handle the situation in a more intelligent way

    Tks in advance
    Fabrizio Guest

  2. #2

    Default Re: Know in user control page_load if an user control event is going to be fired

    hi Fabrizio, I'm not clear with what you want to do. Can you provide another
    scenario without using Map, ZoomIn etc.
    "Fabrizio" <anonymousdiscussions.microsoft.com> wrote in message
    news:E87CBD7C-29D1-4207-A3EE-19CB669A5D91microsoft.com...
    > Hi all,
    > i have built a user control that shows a map and let the user zoom in,
    out, usual stuff.
    > Putting this object in a webform the user can cause page postback without
    touching the user control, so in user control page_load i check
    > if not ib_MapLoaded then LoadMap
    >
    > Unluckily with this logic if the user ask for a ZoomIn the ZoomIn_Click is
    fired after the user control page_load and i load the map twice for every
    event.
    > Is there a way to know in user control page_load if other event of the
    user control are pending ? Or a tip to handle the situation in a more
    intelligent way
    >
    > Tks in advance

    Alessandro Zifiglio Guest

  3. #3

    Default Re: Know in user control page_load if an user control event is going to be fired

    Actually some demo code would be nice too ;P

    "Alessandro Zifiglio" <alessandrozifiglioNO-SPAM-hotmail.com> wrote in
    message news:FkG_b.11046$HO2.2452news.edisontel.com...
    > hi Fabrizio, I'm not clear with what you want to do. Can you provide
    another
    > scenario without using Map, ZoomIn etc.
    > "Fabrizio" <anonymousdiscussions.microsoft.com> wrote in message
    > news:E87CBD7C-29D1-4207-A3EE-19CB669A5D91microsoft.com...
    > > Hi all,
    > > i have built a user control that shows a map and let the user zoom in,
    > out, usual stuff.
    > > Putting this object in a webform the user can cause page postback
    without
    > touching the user control, so in user control page_load i check
    > > if not ib_MapLoaded then LoadMap
    > >
    > > Unluckily with this logic if the user ask for a ZoomIn the ZoomIn_Click
    is
    > fired after the user control page_load and i load the map twice for every
    > event.
    > > Is there a way to know in user control page_load if other event of the
    > user control are pending ? Or a tip to handle the situation in a more
    > intelligent way
    > >
    > > Tks in advance
    >
    >

    Alessandro Zifiglio Guest

  4. #4

    Default Re: Know in user control page_load if an user control event is going to be fired

    Eh, sorry for being not so clear
    Thinking about it i can set the question in a much simple way (the code i could show would not clear the nature of the problem, it's all in my mind :))
    Being in the Page_Load of a WebForm how can i know if an event is going to fire ? a button_click, a grid_itemcommand, and so on
    Can i see also events fired in a user control in the web form
    Can i see the event also in the page load of the user control
    And a last question connected, how do i call a __PostBack from javascript in the correct manner

    P.S. Speaking about my problem i found really good use of the Page_PreRender event, but i would still like to know if i can get this information

    I hope i've been clear, instead i'll try to be more
    Thanks
    Fabrizio
    Fabrizio Guest

  5. #5

    Default Re: Know in user control page_load if an user control event is going to be fired

    Fabrizio,
    In page load you can check to see who fired the event depending on the type
    of webcontrol, one of these always works :
    If Request.Params.Item("btnSubmit") <> Nothing Then
    Else
    End If

    If Request.Params("btnSubmit") <> Nothing Then
    Else
    End If

    If Request.Form("btnSubmit") <> Nothing Then
    Else
    End If
    dim s as string
    s = Request.Params.Get("__EVENTTARGET")

    If s = "btnSubmit" then
    Else
    End if

    As for you dataGrid events you will have to code inside the appropriate
    methods exposed by the dataGrid. This control is a container control and all
    events fired within this container are bubbled up and handled within the
    handlers exposed by this control. A good place to check for click events is
    the OnItemCommad method. This allows you to provide a custom handler for
    the event.


    For your last question, as you would have already noted when using controls
    that postback in asp.net, some javascript code is injected into your page :
    <script language="javascript">
    <!--
    function __doPostBack(eventTarget, eventArgument) {
    var theform = doent.myForm;
    theform.__EVENTTARGET.value = eventTarget;
    theform.__EVENTARGUMENT.value = eventArgument;
    theform.submit();
    }
    // -->
    </script>

    this is the __doPostBack function which is called by any of our controls
    that postback. What it does is it takes an eventTarget(the control ID that
    is postback) and an eventArgument(this is extra info you might want to pass
    along with the event) and sets these values into the hiddenfields before
    causing the form to submit. This is how your webform knows who postback etc.
    You can call this funtion from any clientside code you might have and pass
    it an id.

    Please note however that this script is injected into the page only when
    there is a control on your webform that postsback, so for you to be able to
    call this function from your clientside code you need to have atleast one
    control on your webform that postsback. otherwise you would be calling
    _doPostBack but the function is never there coz it was never injected into
    your page.



    "Fabrizio" <anonymousdiscussions.microsoft.com> wrote in message
    news:5EF98373-1AD8-4DD9-B580-33965F122D33microsoft.com...
    > Eh, sorry for being not so clear.
    > Thinking about it i can set the question in a much simple way (the code i
    could show would not clear the nature of the problem, it's all in my mind
    :)).
    > Being in the Page_Load of a WebForm how can i know if an event is going to
    fire ? a button_click, a grid_itemcommand, and so on.
    > Can i see also events fired in a user control in the web form ?
    > Can i see the event also in the page load of the user control ?
    > And a last question connected, how do i call a __PostBack from javascript
    in the correct manner ?
    >
    > P.S. Speaking about my problem i found really good use of the
    Page_PreRender event, but i would still like to know if i can get this
    information.
    >
    > I hope i've been clear, instead i'll try to be more.
    > Thanks,
    > Fabrizio

    Alessandro Zifiglio Guest

  6. #6

    Default Re: Know in user control page_load if an user control event is going to be fired

    lol fabrizio ;P
    You are welcome :)
    "Fabrizio" <anonymousdiscussions.microsoft.com> wrote in message
    news:BEA66B2A-6CBB-4DC0-8343-9F9D699943E1microsoft.com...
    > Very good tips and explanation Alessandro (both italian and both chatting
    in english? :) ), thanks for your kind help.


    Alessandro Zifiglio Guest

Similar Threads

  1. Page_Load called more than once for user control - newbie question
    By keith in forum ASP.NET Building Controls
    Replies: 0
    Last Post: November 5th, 08:03 PM
  2. Events of datagrid in user control not fired
    By Emmanuel in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: June 28th, 07:58 AM
  3. Access User Control value during Page_Load
    By Cindy in forum ASP.NET Building Controls
    Replies: 1
    Last Post: June 26th, 12:18 AM
  4. Can we fire a user control event when the user does the action
    By Vannela in forum ASP.NET Building Controls
    Replies: 0
    Last Post: November 10th, 10:52 AM
  5. Page Load fired 3 times Web user control is embedded in a custom control
    By Thomas Ekegren in forum ASP.NET Building Controls
    Replies: 0
    Last Post: September 3rd, 05:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •