473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Ajax en the Form_load event and Ajax in serveruser controls

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

Jun 20 '07 #1
2 2184
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" <To*@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
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

Jun 20 '07 #2
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" <To*@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
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


Jun 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Frank Rizzo | last post by:
In vb6, you could do all the resizing of the form (and its constituent controls) in the form_load event, knowing that the form won't show up until the Form_load event was exited. In my vb.net...
0
by: melledge | last post by:
Ajax Developers' Day to Kick Off XTech 2006 Conference Industry experts offer insight into next generation of the Web ALEXANDRIA, VIRGINIA, USA - April 25, 2006 - In response to the rapidly...
1
by: AndiSmith | last post by:
Hi guys, I wondered if anyone could help me with this problem, or even shed some light on the direction I need to take to resolve it? I'm using .NET 2.0 (C# flavor) to build a large user-based...
4
by: Grant Merwitz | last post by:
Hi I am trying to implement the Microsoft Ajax.NET extensions to perform a lookup on a key press of a text box. What this will do is once a user enters a letter into the textbox, this will...
34
by: Smithers | last post by:
I have some logic that populates UI controls with values from App.config. A couple of checkboxes get checked or unchecked; and items loaded into a checked list box. Two reasonable places to put...
3
by: JacekDr | last post by:
Hello, I've got the following problem: I want to add and remove dynamically controls to UpdatePanel. In my user control I have a button, but when I click it I get AsyncPostback and Event for...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: sanrek | last post by:
Hi Folks, Slider control is driving me nuts, below is the code from my test page's page load event, nothing great about code, I have a place holder control into which I am adding a table which...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.