Dynamically Insert Javascript? ajaxToolkit DynamicPopulateExtender

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

Read More

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s