Ajax en the Form_load event and Ajax in serveruser controls

Discussion in 'ASP .Net' started by =?Utf-8?B?VG9u?=, Jun 20, 2007.

  1. Hello,
    I want to understand teh benefits of ajax technology. Does anyone has a good
    website where AJAX EXTENSIONS is worked out so I really understand it.

    There a 2 main questions:
    1) How about the form load event. Why should it fire when I put a button in
    a update panel? Is this necessary and is only the other controls related to
    the update panel send back? Or the whole page (If this is true I really do
    not get it). But please answer me.
    Is het neccesary to execute the form_load full, or is it possible to get
    some more information (variables) which let you know to execute the Full
    form_load or just a part.

    2) I'm using usercontrols and within a user control I want to use ajax. But
    my serverusercontrols uses CreateChildControls and all controls are loaded
    during runtime. My code looks like:
    Dim label1 As New Label
    Label1.ID = ClientID + "L1"
    Label1.Text = lblName
    so all checkboxex hyperlinks, textboxes are dimension in the
    CreateChildControls is it still possible to use AJAX?

    Thanx

    ton
    =?Utf-8?B?VG9u?=, Jun 20, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?VG9u?=

    Ben Rush Guest

    Hello Ton.

    I should have an article coming out in MSDN (eventually) detailing many of
    the things you are asking about, but for now I'll try to see if I can answer
    them directly.

    To answer your second question first, yes, you should be able to use your
    control normally; there should be no differences to its lifetime or
    construction on the server.

    The form load event is necessary because the form must still be instantiated
    on the server in order for the processing of ASP.NET to continue. There are
    plenty of things that are required for controls to render, and a parent form
    is one of them; hence the necessity to have the form be instantiated,
    loaded, etc. just as it normally would. In your case of the button in the
    UpdatePanel, if the Form_Load event never fired, then that would mean the
    Form never responded to the Load event and is therefore not a part of the
    control tree registered and running on the server for your ASP.NET
    application - effectively the core infrastructure of ASP.NET would break
    without a form hosting the server controls. The UpdatePanel is a child
    control of the form, just as the button within the UpdatePanel is.

    What controls are rendered on the server is a slightly more tricky question
    to answer, but there is definitely a solid answer for it - in the standard
    case any and all controls that are associated with an UpdatePanel will be
    rendered, including (but not limited to) those that are inside the
    UpdatePanel as child controls. Unless you are directly leveraging the core
    scripting framework of ASP.NET AJAX (in which case you're responsible for
    the response processing and therefore what gets returned to the client) you
    will be dealing with UpdatePanels and their child controls.

    Not all controls on the form will be rendered, therefore; only those that
    are associated with the UpdatePanels on the page that are registered to
    update due to the post-back event.

    What's confusing you, at the core, is an understanding of what has changed
    on the server. While it is true that one thing that has changed is WHAT gets
    rendered, it's more accurate to understand the true difference is in HOW
    something gets rendered. ASP.NET AJAX overrides the default rendering method
    of the Form and therefore gets to be very selective about what controls (and
    their associated child controls) are rendered. Using the standard HTTP
    stream, the response from the child controls are emitted back to the client
    in a specially formatted block of data that the client framework can parse
    through and use to intelligently update the client content. The output
    stream from all controls (starting at the UpdatePanel and working down) is
    streamed back to the client where it updates the browser content via DHTML
    operations.

    There is more to it than this, and I've glossed over a few details for the
    sake of simplicity over completeness; but I believe you get the basic idea.


    --
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    Ben Rush
    Microsoft .NET Consultant
    http://www.ben-rush.net/blog
    http://www.sideshowsystems.com


    "Ton" <> wrote in message
    news:...
    > Hello,
    > I want to understand teh benefits of ajax technology. Does anyone has a
    > good
    > website where AJAX EXTENSIONS is worked out so I really understand it.
    >
    > There a 2 main questions:
    > 1) How about the form load event. Why should it fire when I put a button
    > in
    > a update panel? Is this necessary and is only the other controls related
    > to
    > the update panel send back? Or the whole page (If this is true I really do
    > not get it). But please answer me.
    > Is het neccesary to execute the form_load full, or is it possible to get
    > some more information (variables) which let you know to execute the Full
    > form_load or just a part.
    >
    > 2) I'm using usercontrols and within a user control I want to use ajax.
    > But
    > my serverusercontrols uses CreateChildControls and all controls are loaded
    > during runtime. My code looks like:
    > Dim label1 As New Label
    > Label1.ID = ClientID + "L1"
    > Label1.Text = lblName
    > so all checkboxex hyperlinks, textboxes are dimension in the
    > CreateChildControls is it still possible to use AJAX?
    >
    > Thanx
    >
    > ton
    >
    Ben Rush, Jun 20, 2007
    #2
    1. Advertising

  3. thank you for your reply. I've experimented a bit but cat achieve what I want:

    (this is still just a test, in my realworld project I want to use this kind
    of code in a userserver control)

    Here the example code in de page load event:
    Dim updatepanel2 As New UpdatePanel
    Dim but3 As New Button
    Dim txt As New TextBox
    updatepanel2.ID = "UP2"
    txt.ID = "txt"
    but3.Text = "ajax added"
    but3.ID = "but3"
    AddHandler but3.Click, AddressOf But3_Click
    Panel2.Controls.Add(but3)
    Panel2.Controls.Add(txt)
    updatepanel2.ContentTemplateContainer.Controls.Add(Panel2)
    Me.Controls.Add(updatepanel2)

    The only existing control is the panel2, because I want to put it in a
    certain place on my web form. If it is possible I would prefer to do this
    even without a panel, but cant figure out (yet) how to use absolute
    positioning in runtime added controls. (But thats another question.

    When running this I get an error, telling tht I had to set the property of
    the control to run at server? OK but how to do programmaticly.

    thanx

    ton


    "Ben Rush" wrote:

    > Hello Ton.
    >
    > I should have an article coming out in MSDN (eventually) detailing many of
    > the things you are asking about, but for now I'll try to see if I can answer
    > them directly.
    >
    > To answer your second question first, yes, you should be able to use your
    > control normally; there should be no differences to its lifetime or
    > construction on the server.
    >
    > The form load event is necessary because the form must still be instantiated
    > on the server in order for the processing of ASP.NET to continue. There are
    > plenty of things that are required for controls to render, and a parent form
    > is one of them; hence the necessity to have the form be instantiated,
    > loaded, etc. just as it normally would. In your case of the button in the
    > UpdatePanel, if the Form_Load event never fired, then that would mean the
    > Form never responded to the Load event and is therefore not a part of the
    > control tree registered and running on the server for your ASP.NET
    > application - effectively the core infrastructure of ASP.NET would break
    > without a form hosting the server controls. The UpdatePanel is a child
    > control of the form, just as the button within the UpdatePanel is.
    >
    > What controls are rendered on the server is a slightly more tricky question
    > to answer, but there is definitely a solid answer for it - in the standard
    > case any and all controls that are associated with an UpdatePanel will be
    > rendered, including (but not limited to) those that are inside the
    > UpdatePanel as child controls. Unless you are directly leveraging the core
    > scripting framework of ASP.NET AJAX (in which case you're responsible for
    > the response processing and therefore what gets returned to the client) you
    > will be dealing with UpdatePanels and their child controls.
    >
    > Not all controls on the form will be rendered, therefore; only those that
    > are associated with the UpdatePanels on the page that are registered to
    > update due to the post-back event.
    >
    > What's confusing you, at the core, is an understanding of what has changed
    > on the server. While it is true that one thing that has changed is WHAT gets
    > rendered, it's more accurate to understand the true difference is in HOW
    > something gets rendered. ASP.NET AJAX overrides the default rendering method
    > of the Form and therefore gets to be very selective about what controls (and
    > their associated child controls) are rendered. Using the standard HTTP
    > stream, the response from the child controls are emitted back to the client
    > in a specially formatted block of data that the client framework can parse
    > through and use to intelligently update the client content. The output
    > stream from all controls (starting at the UpdatePanel and working down) is
    > streamed back to the client where it updates the browser content via DHTML
    > operations.
    >
    > There is more to it than this, and I've glossed over a few details for the
    > sake of simplicity over completeness; but I believe you get the basic idea.
    >
    >
    > --
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~
    > Ben Rush
    > Microsoft .NET Consultant
    > http://www.ben-rush.net/blog
    > http://www.sideshowsystems.com
    >
    >
    > "Ton" <> wrote in message
    > news:...
    > > Hello,
    > > I want to understand teh benefits of ajax technology. Does anyone has a
    > > good
    > > website where AJAX EXTENSIONS is worked out so I really understand it.
    > >
    > > There a 2 main questions:
    > > 1) How about the form load event. Why should it fire when I put a button
    > > in
    > > a update panel? Is this necessary and is only the other controls related
    > > to
    > > the update panel send back? Or the whole page (If this is true I really do
    > > not get it). But please answer me.
    > > Is het neccesary to execute the form_load full, or is it possible to get
    > > some more information (variables) which let you know to execute the Full
    > > form_load or just a part.
    > >
    > > 2) I'm using usercontrols and within a user control I want to use ajax.
    > > But
    > > my serverusercontrols uses CreateChildControls and all controls are loaded
    > > during runtime. My code looks like:
    > > Dim label1 As New Label
    > > Label1.ID = ClientID + "L1"
    > > Label1.Text = lblName
    > > so all checkboxex hyperlinks, textboxes are dimension in the
    > > CreateChildControls is it still possible to use AJAX?
    > >
    > > Thanx
    > >
    > > ton
    > >

    >
    >
    >
    =?Utf-8?B?VG9u?=, Jun 22, 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. Paul Aspinall
    Replies:
    1
    Views:
    400
    Duray AKAR
    Aug 12, 2003
  2. =?Utf-8?B?SmF6eg==?=
    Replies:
    5
    Views:
    466
    Bill Gregg
    Apr 28, 2006
  3. minnie
    Replies:
    1
    Views:
    684
    Andrew Thompson
    Dec 13, 2006
  4. ton
    Replies:
    2
    Views:
    111
  5. Paul Aspinall

    Button causes Form_Load to fire, before Button_Click

    Paul Aspinall, Aug 12, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    114
    Paul Aspinall
    Aug 12, 2003
Loading...

Share This Page