Project Details:
ASP.NET MVC 4
Kendo UI Server Wrappers
C#
Twitter Bootstrap 2.3.2
We're the Kendo UI grid to show grouped results for our data. Since we're using the server wrappers, one of the groups uses a Foreign Key column to show the value of a group instead of the id of the group. I found a way to insert html into the group so that we can customize how it looks, and we're using the Bootstrap popover widget to display detail information when hovering over the group. I found out that in our data, some of the values that will be displayed in the group contain the hash (#) symbol in it, which causes the kendo controls to give an error saying invalid template. I know you can escape the hash with "\\", but this doesn't work correctly when trying to escape it in C# code. If I do a ".Replace("#", "\\#"), what happens is it shows up in the grid like "\#Some more Text" instead of "#Some more Text". How do we escape this in code? The way I'm displaying the code is below:
C# Code:
GeneticModificationName = string.Format("{1} <span class='StrainDetailToolTipClass' data-placement='right' data-toggle='popover' data-content='<div>{0}</div>' title='Strain Description'><i class='icon-info-sign'></i></span>"
+ " <span style='color: #245fac; font-size: 10px !important; font-weight: bold;'>Genotype Order: ({2})</span>",
ugStrain.Strain.Description != null ? Server.HtmlEncode(ugStrain.Strain.Description.Replace("#", @"\\#")) : "No Strain Description Available.",
Server.HtmlEncode(ugStrain.Strain.Name.Replace("#", @"\\#")), sb.ToString())
Grid Column Snippet from Server Wrapper:
columns.ForeignKey(m => m.UserGroupStrainId, (System.Collections.IEnumerable)ViewData["Strains"], "StrainId", "GeneticModificationName").Title("Strain").Hidden();
ASP.NET MVC 4
Kendo UI Server Wrappers
C#
Twitter Bootstrap 2.3.2
We're the Kendo UI grid to show grouped results for our data. Since we're using the server wrappers, one of the groups uses a Foreign Key column to show the value of a group instead of the id of the group. I found a way to insert html into the group so that we can customize how it looks, and we're using the Bootstrap popover widget to display detail information when hovering over the group. I found out that in our data, some of the values that will be displayed in the group contain the hash (#) symbol in it, which causes the kendo controls to give an error saying invalid template. I know you can escape the hash with "\\", but this doesn't work correctly when trying to escape it in C# code. If I do a ".Replace("#", "\\#"), what happens is it shows up in the grid like "\#Some more Text" instead of "#Some more Text". How do we escape this in code? The way I'm displaying the code is below:
C# Code:
GeneticModificationName = string.Format("{1} <span class='StrainDetailToolTipClass' data-placement='right' data-toggle='popover' data-content='<div>{0}</div>' title='Strain Description'><i class='icon-info-sign'></i></span>"
+ " <span style='color: #245fac; font-size: 10px !important; font-weight: bold;'>Genotype Order: ({2})</span>",
ugStrain.Strain.Description != null ? Server.HtmlEncode(ugStrain.Strain.Description.Replace("#", @"\\#")) : "No Strain Description Available.",
Server.HtmlEncode(ugStrain.Strain.Name.Replace("#", @"\\#")), sb.ToString())
Grid Column Snippet from Server Wrapper:
columns.ForeignKey(m => m.UserGroupStrainId, (System.Collections.IEnumerable)ViewData["Strains"], "StrainId", "GeneticModificationName").Title("Strain").Hidden();