Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Ajax en the Form_load event and Ajax in serveruser controls

Reply
Thread Tools

Ajax en the Form_load event and Ajax in serveruser controls

 
 
=?Utf-8?B?VG9u?=
Guest
Posts: n/a
 
      06-20-2007
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

 
Reply With Quote
 
 
 
 
Ben Rush
Guest
Posts: n/a
 
      06-20-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9u?=
Guest
Posts: n/a
 
      06-22-2007
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX IDE and AJAX TOOL--The Release of JoyiStar AJAX WebShop 3 Beta minnie Java 1 12-13-2006 06:29 AM
how do I know it's posted back due to a button click in Form_Load =?Utf-8?B?SmF6eg==?= ASP .Net 5 04-28-2006 07:15 PM
How can I use session state information in a serveruser control ton ASP .Net Building Controls 2 02-06-2004 09:50 AM
Button causes Form_Load to fire, before Button_Click Paul Aspinall ASP .Net 1 08-12-2003 07:12 PM
Button causes Form_Load to fire, before Button_Click Paul Aspinall ASP .Net Web Controls 0 08-12-2003 05:08 PM



Advertisments