how to add several HTML elements to the web page dynamically using AJAX

T

ton

Hi,

I'm using AJAXPRO this works very well.

What I want to do is to add new page elements at my web site without using a
postback. And I do not mean listitems but a complete dialog. Let me give an
example:

in my application which will contain of several pages I'll use a
filter/query mechanism, so if the user wants to add a new filter or modify
an existing one I would like to:
1) run a AJAXPRO server function
2) the result will be (?) several elements generated via vb code, and added
on the website
it could be some elements like
- a panel
- several labels with text on
- several textboxes
- several check boxes
- a listbox
- a view buttons
(- if possible an extra scrip block)

all code will use AJAXPRO functions to get and set the data

is this possible?
And is it easy to do.

My alternative is that i add all these controls to my webpage in a panel and
make this panel hidden, the disadventage is that i would have to include
this panel in more webpages, which will cause maintenance in the future.

Thanx

Ton
 
B

bruce barker

it looks like you want the feature supplied by the update panel in the .net
ajax toolkit. you can do it with any ajax library (have server generate html
javascript inserts into the dom). also look at jquery which is client
concenteric and allows creating control from javascript.



-- bruce (sqlwork.com)
 
T

ton

Is it? Is it possible to add dynamically controls in the update panel at
runtime? If so then it is easy, but can a script with several function to
the page as well ?

I did not know that. How can that be established?

The controls, I supoose can be added via the contenttemplate of the update
panel (why didn't I think of it), but what about the script can it be added
to the page at runtime? But how is this done?.

thanx


ton
 
T

ton

i 've made some test:
a simple form with the scriptmanager and the updatepanel
after clicking the button the next sub is called:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim but As New Button
but.Text = "YES !!"
but.ID = "x"
but.Attributes("onclick") = "alert('pushed');"
AddHandler but.Click, AddressOf Me.Button1_Click
UpdatePanel1.ContentTemplateContainer.Controls.Add(but)
Dim Textbox1 As New TextBox
Textbox1.Text = "and a new textbox !"
Textbox1.ID = "xx"
UpdatePanel1.ContentTemplateContainer.Controls.Add(Textbox1)
End Sub
without the post back I see the other button and the textbox is also
appearing, but when pushing it both controls are gone? There is a postback
but the procedure is not executed because (I guess) the postback is "not
complete" the added button is not added now, thats why the added addhandler
which should bring it back again is not fired.
With or without the addhandler is the same result.
The pushed messagebox is working (the alert is fired), button at time still
visible but after clicker the alert the button and the textbox are gone.

How can this be corrected, is there a way to read the state of de website
which controls should be "active"


thanks

ton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top