Dynamically Insert Javascript? ajaxToolkit DynamicPopulateExtender

A

andyr

I would like to dynamically insert a javascript call with with data
retrived from the database.

All I am trying to do is dynamically inserting the following <script
type="text/javascript">alert(retrieved_database_id);</script> to a
panel using the ajaxToolkit:DynamicPopulateExtender

Can someone enlighting me where I am going wrong or the best way to go
about what I am trying to achieve.

<ajaxToolkit:DynamicPopulateExtender ID="dp" BehaviorID="dp1"
runat="server" TargetControlID="panel1"
ClearContentsDuringUpdate="true" PopulateTriggerControlID="lbMessage"
ServiceMethod="GetDatabaseId" />

This is what I return from the webmethod:
public static string GetDatabaseId(string contextKey)
{
//Get retrived_database_id

return String.Format("<script type=\"text/javascript\">alert({0});</
script>", retrived_database_id)
}

Thanks In Advance
 
M

Michael Nemtsev [MVP]

Hello (e-mail address removed),

1) Do u use the latest March version of Toolkit?

2) Where are your
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]

attributes? or it's the PageMethod?

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

I would like to dynamically insert a javascript call with with data
retrived from the database.

All I am trying to do is dynamically inserting the following <script
type="text/javascript">alert(retrieved_database_id);</script> to a
panel using the ajaxToolkit:DynamicPopulateExtender

Can someone enlighting me where I am going wrong or the best way to go
about what I am trying to achieve.

<ajaxToolkit:DynamicPopulateExtender ID="dp" BehaviorID="dp1"
runat="server" TargetControlID="panel1"
ClearContentsDuringUpdate="true" PopulateTriggerControlID="lbMessage"
ServiceMethod="GetDatabaseId" />

This is what I return from the webmethod:
public static string GetDatabaseId(string contextKey)
{
//Get retrived_database_id
return String.Format("<script type=\"text/javascript\">alert({0});</
script>> ", retrived_database_id)
script>>
 

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,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top