+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Sitefinity TemplateParser

Sitefinity TemplateParser

4 posts, 0 answered
  1. Richard Baugh
    Richard Baugh avatar
    201 posts
    Registered:
    22 Aug 2012
    10 Sep 2009
    Link to this post
    I had created an embedded template for a module. This template had a script tag with the runat="server" attribute. Upon the template being rendered to the web page, this code block was outputed as if it was a javascript tag. The code was not executed as a normal script tag with the runat attribute. Since this is an embedded template, it is using the Sitefinity TemplateParser.

    I am not sure if this was intended or just an oversight.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2009
    Link to this post
    Hello Richard Baugh,

    I tried using the following code on Page_Load with an embedded template and the code was executed.

    <script type="text/javascript" runat="server"
     
      $(document).ready(function () { alert("ALERT!");}); 
         
         
    </script> 

    I also was able to show the alert without using jQuert by calling function onclick event of a button.

    Kind regards,
    Ivan Dimitrov
    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.
  3. Richard Baugh
    Richard Baugh avatar
    201 posts
    Registered:
    22 Aug 2012
    15 Sep 2009
    Link to this post
    Sorry I didn't clarify myself. I was trying to execute server side code using the script tag with runat="server".

    <script runat="server"
        protected void Page_Load(object sender, EventArgs e) 
        { 
            // some code here 
        } 
    </script> 

    After the template was rendered on the client side, this exact code was visible when viewing the source from the browser. This code should have been executed on the server side and not rendered on the client side.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Sep 2009
    Link to this post
    Hi Richard Baugh,

    Sitefinity parser does not support compilation of server code from the template. You can add your logic in the view or use ASP.NET parser.

    Greetings,
    Ivan Dimitrov
    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.
Register for webinar
4 posts, 0 answered