Mix html and code asp.net - html

I'm trying to join two strings but I want them to be divided by a break line.
This is my code:
<td>#(string.Join("<br /> ", report.TimeReportProjects.Select(x => x.Project.ProjectName)))</td>
<td>#(string.Join("<br /> ", report.TimeReportProjects.Select(x => x.Description.Shorten(35))))</td>
<td>#(data.StartHour + ":" + data.StartMinute.ToString("00") + " - " + data.EndHour + ":" + data.EndMinute.ToString("00"))</td>
<td>#(Math.Floor(hours) + ":" + TimeSpan.FromHours(hours).Minutes.ToString("00"))</td>
The "br/>" tag will just be read as a string which is not to strange I assume, I know if i want to mix html code in a code block I should use #: but I am not sure how to use that in this case.

There is a Html.Raw method that should help you. It can be applied like so:
<td>#Html.Raw(string.Join("<br />", report.TimeReportProjects.Select(x => x.Project.ProjectName)))</td>

Related

& is always being decoded (which I don't want) using HtmlOutput or HtmlTemplate

I've created a script one or two years ago, which exports all strings for Android and iOS.
It shows a dialog with textareas for each language with the full strings file in the textarea.
It always worked fine until UiApp was removed.
So right now I've tried using HtmlService and HtmlTemplate. Both result in & being converted to &.
HtmlOutput I'm using this code:
var htmlOutput = HtmlService.createHtmlOutput().setWidth(800).setHeight(600);
htmlOutput.append('<textarea style="width: 100%; height: 100px;" id="' + id + '">' + content + '</textarea>');
This produces a textarea with for example this:
<string name="terms">Terms & Privacy</string>
For HtmlTemplate I've tried:
var templateString = '<textarea style="width: 100%; height: 100px;" id="' + ("export_" + i) + '">' + '<?!=' + texts[i] + '?>' + '</textarea>';
// Or this one without Force-printing scriptlets
// var templateString = '<textarea style="width: 100%; height: 100px;" id="' + ("export_" + i) + '">' + texts[i] + '</textarea>';
HtmlService.createTemplate(templateString).evaluate().setWidth(800).setHeight(600);
I tried to use Force-printing scriptlets which gives an even weirder output:
Terms & Privacy
It doesn't even give the <string> tags around it. When I leave the Force-printing scriptlets away it gives the same result as HtmlOutput.
Some extra info
Before I'm exporting it using these methods I'm making sure every string is being converted so it will be the correct output for Android and iOS. For example I'm using this piece of code to convert a string:
var text = o.texts[textIndex];
text = text.replace(/&/g, "&");
'<string name="' + identifier + '">' + text + '</string>' + "\n";
This is of course not all, but just to give an idea how the script works.
Solution
You can utilize the appendUntrusted() method to return HTML without being parsed. Everything you append to output via this method will not be treated as markup (think of it as setting textContent property).
Sample
var htmlOutput = HtmlService.createHtmlOutput().setWidth(800).setHeight(600);
htmlOutput.append('<textarea style="width: 100%; height: 100px;" id="' + id + '">');
htmlOutput.appendUntrusted(content);
htmlOutput.append('</textarea>');
Output
And this is a sample output (I used '& & and two' as content)
Useful links
appendUntrusted() method reference;
You can try replacing & with literal &:
text = text.replace(/&/g, "&amp;");
<textarea><string>Terms &amp;Privacy</string></textarea>
<textarea></textarea>
<script>
document.querySelectorAll('textarea')[1].innerText = "Terms & Conditions"
</script>

multi-line in aurelia component html attribute property

This is a weird question about possibly embedding a string in an aurelia html file within the attribute tag but I would like to keep my tab and line formatting.
So, in my TS file I have the following:
this.queryDateStart += "type=EntityOne&dateQueryString=";
this.queryDateStart += "" +
"eOr( " +
"eAnd( " +
"eAnd( facetName:isExcluded AND facetValue:No );" +
"dAnd( facetName:deadlineDate AND "+ dateRangePredicate + ");" +
"); " +
"dOr( " +
"(facetName:excludedUntilDate AND "+ dateRangePredicate + ")" +
");" +
");"
And instead of having the following:
<section as-element="ab-deadlines" data-query="${queryDateStart}"></section>
I would like to actually pass the literal string from above.
But with the line spaces.
Would that break anything?
So for example ( going to try this today) - in my html file I would put:
<section as-element="ab-deadlines"
data-query="
eOr(
eAnd(
eAnd( facetName:isExcluded AND facetValue:No );
dAnd( facetName:deadlineDate AND ${dateRangePredicate} );
);
dOr(
(facetName:excludedUntilDate AND + ${dateRangePredicate} )
);
);"></section>
About breaking: it shouldn't break anything. In the end, it's just normal HTML attribute, and as long as the spec allows it, it works in Aurelia, as Aurelia works directly, and plainly with HTML elements.
You can see it yourself at this sandbox https://codesandbox.io/s/z20qx0q263

Line breaks in SSRS report

I have an address Field in my SSRS report that displays as below
PARADISE BALTI
104
WHITWORTH ROAD
ROCHDALE
LANCASHIRE
OL12 0JJ
How do I format this so it all appears on one line?
For this you have to write expression and concatenate string like
=First(Fields!Name.Value, "DataSet") + "<br/>" + First(Fields!Address1.Value, "DataSet") + "<br/>" + First(Fields!City.Value, "DataSet") + ", " + First(Fields!State.Value, "DataSet") + " " + First(Fields!Zip.Value, "DataSet")
Take a text box and create a placeholder and set value as an expression shown above.. Then choose markerup type as HTML ...

Including special chars in htmlText

How can I include special characters in htmlText? Specifically, I need to include this symbol: Ø. So far I tried ∅, \u2205 and \u2300, but the symbol is never shown. Copying the char itself only works with text property, so what is the appropriate way to include special chars?
This is my code:
this.text1.htmlText = toHtmlText(s);
function toHtmlText(s:String):String{
return "<font size=\"32\">" +
"\u2205" + // also tried '∅' and '\u2300'
" </font><font size=\"64\">" +
s +
"</font>";
}
try this,
this.text1.htmlText = toHtmlText(s);
function toHtmlText(s:String):String{
return "<font size=\"32\">" +
"\Ø" +
" </font><font size=\"64\">" +
s +
"</font>";
}
find all special characters here: http://dev.w3.org/html5/html-author/charref
Use this following HTML entity:
Ø
You can also go through this link http://www.utexas.edu/learn/html/spchar.html

SSRS report formatting for excel

I am writing an SSRS report in which my client wants the report header to contain the criteria on which the report is based (actually, this is the report variables, such as date).
I tried to do this with textboxes, but can't seem to position the textboxes in such a way that upon export to excel there aren't crazy cell merges.
I also tried to do this with a table in the report body, but got the variable added to each line of the report.
I don't see a position property, as if I was working in just a web form, but am at a loss as to what to do. Any suggestions? Thanks!
Cell merges are a fact of life when exporting to Excel unfortunately, that's how the report rendering engine tries to maintain fidelity with the original report design. The best way to minimise this is to ensure the edges of the report elements align with each other as much as possible, so that the renderer can align the report without having to merge cells.
What you are doing by putting textboxes in the report header to display the value of selected report parameters is a good approach that is commonly used, so keep experimenting with the layout to get it to align correctly.
If you can describe what is happening when you export the report in a bit more detail I might be able to offer some more advice.
In my reports, I add an additional table at the end of the report and assign a page break before the tablix. In the large, single-cell table, I write sentences using quoted text, built-in fields, and parameter values to list all of the parameter information. I label the Name of the Tablix "Parameters" so when the report is downloaded, all of the parameter data goes with it in a nice, non-invasive format. When troubleshooting reports this has proved very valuable.
Here's an example:
=Globals!ReportName + " run by " + User!UserID + " on " + FormatDateTime(Globals!ExecutionTime, DateFormat.ShortDate) + ". "
+ vbcrlf +
"Parameters: " + "Program ("+Parameters!BusinessEntityID.Label+ "), Deliverable Status Code (" + Join(Parameters!DeliverableStatusCode.Label, ", ") +
"), Science Area (" + Parameters!ScienceAreaID.Label + "), Thrust Area (" + Parameters!ThrustAreaID.Label + "), Center (" + Parameters!CenterID.Label + ") "
+ IIF(Parameters!TaskActiveFrom.Value is Nothing, "", ", Tasks Active between "+ FormatDateTime(Parameters!TaskActiveFrom.Label, DateFormat.ShortDate)
+ " and " + FormatDateTime(Parameters!TaskActiveTo.Label, DateFormat.ShortDate))
+IIF(Parameters!TaskStartFrom.Value is Nothing, "", ", Tasks Started between " + FormatDateTime(Parameters!TaskStartFrom.Label, DateFormat.ShortDate)
+ " and " + FormatDateTime(Parameters!TaskStartTo.Label, Dateformat.ShortDate))
+ IIF(Parameters!DeliverablePlannedFrom.Value is NOTHING, "", ", Deliverable Due Date between " + FormatDateTime(Parameters!DeliverablePlannedFrom.Label, Dateformat.ShortDate)
+ " and " + FormatDateTime(Parameters!DeliverablePlannedTo.Label, Dateformat.ShortDate))
+ IIF(Parameters!DeliverableExtendedFrom.Value is Nothing, "", ", Deliverable Revised Due Date between " + FormatDateTime(Parameters!DeliverableExtendedFrom.Label, Dateformat.ShortDate)
+ " and " + FormatDateTime(Parameters!DeliverableExtendedTo.Label, Dateformat.ShortDate))
+ IIF(Parameters!PublicationReceivedDateFrom.Value is NOTHING, "", ", Publication Received Date between " + FormatDateTime(Parameters!PublicationReceivedDateFrom.Label, Dateformat.ShortDate)
+ " and " + FormatDateTime(Parameters!PublicationReceivedDateFrom.Label, Dateformat.ShortDate))