template syntax question

4 posts, 0 answers
  1. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 27 Jan 2015 Link to this post

    Hi,
    I think this is a general question regarding template syntax.

    I am trying to define a grid column template in a child grid template so that it is rendered as an anchor  (which I want to later use to re-position in the page). For example : 
    <a href="#Myref1234">Bookmark</a>


    In the column's ClientTemplate I have

    .ClientTemplate("<a href='\\#\\#=Reference\\#'>Bookmark</a>")

    But the result is an Invalid template
    <a href='##=Reference#'>Bookmark</a>


    This template without the leading \\# is accpeted and produces valid HTML:
    .ClientTemplate("<a href='\\#=Reference\\#'>Bookmark</a>")


    What syntax should I use to allow me to prefix the href with the # ?

    Or perhaps you can suggest another way to allow me to reposition on the page?

    Thanks
    Craig

     
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 29 Jan 2015 Link to this post

    Hello Craig,

    The template should be as follows:

    .ClientTemplate("<a href='\\\\\\#\\#=Reference\\#'>Bookmark</a>");

     

    Regards,
    Nikolay Rusev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 29 Jan 2015 in reply to Nikolay Rusev Link to this post

    Hi Nikolay,
    That works great.

    What are the rules regarding the number of levels of escape characters (\\) to apply?

    Craig
  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 30 Jan 2015 Link to this post

    Hello Craig,

    Here is the idea behind all this - you need two back slashes \\ to escape hash # symbol in template. However as this template is inside another template (detail grid) you need two more backslashes \\, each of which is escaped with one more.

    I hope this makes things a bit more clearer. 

    Regards,
    Nikolay Rusev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready