Javascript in usercontrol shown in ajax request not seen

3 posts, 0 answers
  1. rh
    rh avatar
    193 posts
    Member since:
    Jan 2007

    Posted 06 Jan 2008 Link to this post

    I have a scenario where I have a usercontrol that is initially not visible on a page. If the user selects a certain option in a combo box then the user control is shown as part of an ajax request using RadAjaxManager Prometheus. This works and the user control is dynamically displayed on the page.

    However, the user control contains some javascript that is specific to the controls within the user control. That is, it uses <%= SomeControl.ClientID %> within the javascript to get references to the controls within the user control. The problem is that the javascript isn't visible after displaying the user control. When I try to call functions that are contained within the user control I get an error that it can't find the function. How do I make the functions available after showing the user control as part of a ajax request?
  2. rh
    rh avatar
    193 posts
    Member since:
    Jan 2007

    Posted 06 Jan 2008 Link to this post

    I've tried using the ResponseScripts collection of the RadAjaxManager but it isn't working. My script includes functions that then get called when an action occures (like a button click). I'm guessing maybe ResponseScripts is only for code to immediately run (like an alert box) and not for functions to be registered with the page to be called?

    It is also unclear as to whether or not the script string should include the script tag.

    The key to this not working is that the user control is initially not visible. If I make the user control initially visible then everything works fine because the javascript is parsed with the initial page load. But by loading the usercontrol as part of the ajax request then ASP.NET AJAX just shoves the javascript into the inner HTML of the control to update and doesn't register it with the page.

    I haven't had any luck with the ResponseScripts of RadAjaxManger, Page.RegisterClientScriptBlock, or ScriptManager.RegisterClientScript block. Nothing seems to be able to parse the functions in my script and make them available on the page.
  3. DevCraft R3 2016 release webinar banner
  4. John
    John avatar
    416 posts
    Member since:
    Oct 2006

    Posted 08 Jan 2008 Link to this post

    hi rh

    You can enclose this script in RadScriptBlock.



    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

    <script type="text/javascript">

    function Click()







    Thank you...
    <John:Peel />
Back to Top