By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Aug 22 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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)
"ton" wrote:
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

Aug 22 '08 #2

P: n/a
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
"bruce barker" <br*********@discussions.microsoft.comschreef in bericht
news:29**********************************@microsof t.com...
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)
"ton" wrote:
>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

Aug 22 '08 #3

P: n/a
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
"ton" <to*@nospam.nlschreef in bericht
news:77***************************@cache5.tilbu1.n b.home.nl...
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
"bruce barker" <br*********@discussions.microsoft.comschreef in bericht
news:29**********************************@microsof t.com...
>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)
"ton" wrote:
>>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

Aug 22 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.