0

I am following this article. http://www.codeproject.com/Articles/23768/Load-and-Display-Page-Contents-Asynchronously-with

I have a usercontrol with some javascript codes. Lets say there is a method called alertMe(msg) in javascript. And i am calling this from c#. It is not calling. i am using this.page.clientscript.registerscriptblock function.

Even the javascript is not rendered in the page. I did check it by pressing F12 in chrome browser and went to console and typed the method name, it said undefined.

  1. Will javascript not rendered in page when we use renderControl method
  2. While asynchronosly loading user controls, what is the way to call javascript methods from c#.
John Supakin
  • 141
  • 5
  • 14

1 Answers1

1

Have you tried ScriptManager instead of Page.ClientScript? I think that the script is not available during a partial postback if it is not registered with the ScriptManager.

Looks like this:

ScriptManager.RegisterStartupScript(Page, this.GetType(), "DatePickerScript" clientScript, true);
Mahesh
  • 1,465
  • 4
  • 19
  • 23
  • Thanks Mahesh. It was Good idea. Do you have any suggestion about why the javascript which is written inside user control is not getting rendered. For example, i am having Telerik RadGrid inside the UserControl. Telerik will register some Javascript libraries. I hope that is not rendering, so none of the functionality is working in the RadGrid. Thanks for spending your time here. – John Supakin Dec 07 '12 at 09:54
  • As per my idea, Java script will not get render on browser if you are using update panel. You need to call ScriptManager.RegisterStartupScript() method. If If this answer is use full tick the accept this answer. – Mahesh Dec 07 '12 at 12:09