ScriptManager.RegisterClientScriptBlock not working with UpdatePanel

P

Pselus

I have a dynamically created page. The page creates an UpdatePanel
(created at Design time) which has an ASP:Table (design time) in it.
The table has rows with a textbox (run time) that runs some Javascript
code when it is typed in.
There is also a linkbutton (run time) next to this textbox that when
clicked uses Ajax to reload the Javascript method.
However, the Javascript is not being updated.

I realize that most people post this question and the answer is "Use
ScriptManager instead of Page.ClientScript" bu tthe problem is that
I'm already using ScriptManager.

Here is my line of code:
ScriptManager.RegisterClientScriptBlock(updpnlHolder,
typeof(UpdatePanel), "AddOnLife", code, true);

I've tried registering it to the UpdatePanel, to the Page, to the
ASP:Table inside the Panel, even to the Textbox. The Textbox is the
only one that errors (saying the control must be in the Page control
tree) but the rest of them go through without erroring...but they
don't actually update the Javascript.

Anyone have any ideas?
 
E

Erjan Gavalji

Hi Pselus,

How do you create the page and the update panel with the table dynamicaly,
while having them in design time? The statement seems fine to me...

Cheers,
Erjan
 
B

bruce barker

how do you know its not added? this stuff is easier to debug with
firefox and its dev tools (firebug and dev tool). you can see added
script and dom changes done by ajax calls.

-- bruce (sqlwork.com)
 
P

Pselus

Hi Pselus,

How do you create the page and the update panel with the table dynamicaly,
while having them in design time? The statement seems fine to me...

Cheers,
Erjan

The updatepanel and table are created at design time but the table is
populated with controls at run time.
 
P

Pselus

how do you know its not added? this stuff is easier to debug with
firefox and its dev tools (firebug and dev tool). you can see added
script and dom changes done by ajax calls.

-- bruce (sqlwork.com)

I know that it hasn't changed because I can see the Javascript method
when I view the page source. It is still the same in the page source
and the outcome is still the same.
 
P

Pselus

I have a dynamically created page.  The page creates an UpdatePanel
(created at Design time) which has an ASP:Table (design time) in it.
The table has rows with a textbox (run time) that runs some Javascript
code when it is typed in.
There is also a linkbutton (run time) next to this textbox that when
clicked uses Ajax to reload the Javascript method.
However, the Javascript is not being updated.

I realize that most people post this question and the answer is "Use
ScriptManager instead of Page.ClientScript" bu tthe problem is that
I'm already using ScriptManager.

Here is my line of code:
ScriptManager.RegisterClientScriptBlock(updpnlHolder,
typeof(UpdatePanel), "AddOnLife", code, true);

I've tried registering it to the UpdatePanel, to the Page, to the
ASP:Table inside the Panel, even to the Textbox.  The Textbox is the
only one that errors (saying the control must be in the Page control
tree) but the rest of them go through without erroring...but they
don't actually update the Javascript.

Anyone have any ideas?

I think I figured it out.
The Javascript code was being registered twice on a postback (or on an
Ajax postback). It was being registered like normal, then it went
through the code to change the Javascript code and registered it
again. The second registration wasn't being recognized.
I put a check around the first registration to check the control
causing the Postback and if it was the link that was supposed to
create the new Javascript I made sure not to register it the first
time.
Works perfectly now.
:)
 

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

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top