Inline Javascript

2 posts, 0 answers
  1. Nik
    Nik avatar
    51 posts
    Member since:
    Sep 2009

    Posted 02 Oct 2009 Link to this post

    I currently have a usercontrol that is loaded into my tooltip. The UC needs to have our product rating script on it that comes from power reviews. This is an inline JS thats placed in the code where we want the rating stars to appear.
    <asp:Literal ID="ltrCustomerReviewSnippet" runat="server" Visible="false"
      <div class="pr_snippet_category" > 
        <span id="pr_snippet_headertxt" class="bv-light-grey">Product Rating</span> 
        <script type="text/javascript"
           var pr_snippet_min_reviews=0; POWERREVIEWS.display.snippet(document, { pr_page_id : "PAGE_ID" });  

    I know there are issues with JS running with Ajax, as per this thread, but I can't understand how to use RegisterStartupScripts or anything else of that sort to perform inline JS such as this. Can anyone explain this, maybe with some code snippets?

  2. Tsvetie
    Tsvetie avatar
    1517 posts

    Posted 07 Oct 2009 Link to this post

    Hello Nik,
    You can register script that will execute after the UserControl is loaded in the RadToolTip the following way:
    protected void RadToolTipManager1_AjaxUpdate(object sender, ToolTipUpdateEventArgs e) 
        e.UpdatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("Test")); 
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "startupscript""alert(1);"true); 

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top