Reputation: 193
I am using knockout.js with Asp.NET and visual studio (2012 but I get the same problem with 2010 and 2013). My code looks something like this :
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="Solution.ascx.Test" %>
<div>
<span data-bind="value: '<%= String.Empty%>'"></span>
</div>
Every time I paste this code or press ctrl+k, ctrl+d (format file), i get those weird spaces after the code render block. (replaced as XXXX in the following snippet for visibility)
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="Solution.ascx.Test" %>
<div>
<span data-bind="value: '<%= String.Empty%>XXXX'"></span>
</div>
Problem only occurs when using the "data-bind" tag.
I tried disabling "indent contents" in client Options > Text Editor > HTML > Formatting > Tag Specific Options > HTML tag > span with no luck. Does anyone have a solution for this ? Not only is it very annoying but knockout is also parsing those spaces and throwing exceptions.
Upvotes: 1
Views: 186
Reputation: 1093
It's not a problem with the formatting of the text editor, it's a problem with the -bind attribute. For whatever reason, VS does not like this. I've scoured the internet since reading this question, and cannot find any good reason.
I did find, which may be your best method, someone had the exact problem using MVC: using @data-bind in ASP.NET MVC htmlAttributes throws exception
simply use JQuery to change data_bind to data-bind on the fly (as described in the post) and you should be good to go.
Upvotes: 1