Decoding a text with percent symbol in Asp.net MVC Razor - asp.net-mvc-4

There is a text on my web site html like;
%
that's about percentage you may know. I can't print it as percent symbol. I've tried Html helper's Raw method;
#Html.Raw(item.baslik)
but this produces just;
%
how can I achieve this?

That means item.baslik is already HTML encoded. Try Html.Raw(HttpUtility.HtmlDecode(item.baslik)) instead. Or better, don't encode your property values prematurely, if you have access to the code.

Related

Netsuite PDF Templating: get number of pages as attribute

I am templating pdfs in Netsuite using freemarker and I want to display the footer only on the last page. I have been doing some research, but couldn't find a solution (since looks like the environment does not allow me to include or import libs), so I thought that just comparing the number of the page with the total pages in an if tag would be a nice and easy workaround. I already know how to display the numbers by using the <pagenumber/> and <totalpages/> tags, but still cannot get them as values so I can use them like this:
<#if (pagenumber == totalpages) >
... footer html...
</#if>
Any ideas of how or where can I get those values from?
The approach you are trying won't work, because you are mixing BFO and Freemarker syntax. Netsuite uses two different "engines" to process PDF Templates. The first step is Freemarker, which merges the record fields with your template and produces an XML file, which is then converted by BFO into a PDF file. The <totalpages/> element is meaningless to Freemarker, as it is only converted into a number by BFO later.
Unfortunately, the ability to add a footer to only the last page of a document is currently a limitation of BFO, as per the BFO FAQ:
At the moment we do not have a facility for explicitly assigning a
footer or header to the last page in a document when the number of
pages is unknown.
You CAN add it after a page break - and put the page break at the end of the body
<pbr footer="nlfooter" footer-height="25%"></pbr>
</body>
The issue here is - on a one page output - you will get 2 pages minimum... it will always ADD a page for the disclaimer / footer...

Converting raw print codes to a printer using a VB.net web page

I've run into a situation I've never encountered before. I'm working with a shipping API for an e-commerce site and I've retrieved a shipping label. The problem is that the code used for the label is what appears to be raw print codes. They look something like this:
N
Q822,24
R40,0
S4
D15
ZB
A760,120,1,1,1,1,N,"Interlink Express"
A735,080,1,1,1,1,N,"www.interlinkexpress.com"
A706,033,1,1,1,1,N,"Sender"
.... more codes like this
LO001,330,765,10
LO001,025,765,1
LO001,192,590,1
LO001,330,765,10
.... more codes like this
P1
What I'd like to be able to do is convert it to a graphic or something else that I can print from a web page. The problem is that I can't find any ways to deal with this particular type of information, since it's not in a web-standard format (it's not HTML, XML, JSON, etc.)
How would I deal with something like this?
Thanks.
In the end, I solved this a different way. Apparently the shipping company was able to use an Accept: text/html header from my HttpWebRequest and I got an HTML-formatted printer label. So we're good. Thanks.

Remove extra ASCII symbol rendering in PDF

I have a user that is storing a 'registered trademark' symbol in her name in our database and when we retrieve it when the database it renders correctly, but when we actually place it onto the website itself in HTML it renders with an extra 'A' symbol in front of it:
You can see above the database value compared to what is rendered in the PDF file. I can access the database value in the backend and edit it through vb code but I am really not sure how or what the code would be to do that as I don't want to remove all ASCII characters just the extra symbol being generated and rendered in the PDF.
Any idea how to do this would be great.
I think the Main-Problem is that you generate wrong HTML-Code by just inserting your Database-Result-Strings into your Website
You can encode your Database String to HTML by using the HtmlEncode-Function from HttpUtility in .NET
Here is an Example from vb.net
myEncodedString = HttpUtility.HtmlEncode(myString)
If you use "myEncodedString" inside your WebPage you'll get no additional Characters and a valid HTML-Code.

Simple paragraph formatting of strings in mvc 4 or 5

I'm using MVC 4 I have a string being stored in SQL Server as varchar(Max) my data annotations in the model specify DataType(DataType.MultilineText). I would think that the helpers for displaying this type of text would not just spit it all out on one line, but none of the formatting from the multiline text box is coming through when I display it on a page using the basic scaffolding. But the formatting does show up when I go to edit that description on the crud side. Why is this so hard to do out of the box. I can use a MVC 4 or 5 solution. I would think they would be similar.
I use the following methods to display on my page:
#Html.DisplayNameFor(model => model.InstructionEn)
&
#recipe.RecipeInstructionsEn
I'm thinking something that will replace New lines with tags might work. But how would I go about that? I know the New line formatting is there.
I also thought about using markdown, but wouldn't know where to start.
You need to replace the plain text newline character (\n) with the HTML one (<br />):
#Html.Raw(recipe.RecipeInstructionsEn.Replace("\n", "<br />"))
The use of Html.Raw prevents the default HTML encoding that Razor applies. Without it, the newline entity will display as "<br />" instead of acting as an HTML line break.

facebook api query string issue

I develop a facebook api with asp.net , I have to send query string but this querystring may include special characters like ( ı, ç ö, ş, ğ ). When I send query string with special characters, facebook returns me an error-
The URL http://apps.facebook.com/sportsfanarena/Results.aspx?s=13&co=3&ci=Bal%c4%b1kesir&g=0 is not valid.
The "ci" variable's value is "Balıkesir".
Is there any solution to handle it?
I believe you need to use URL encoding to send characters like that, though I may be mistaken.
Here is an online utility which will take text and encode/decode it in URL encoding.
Try encoding the word you are wanting to send using this utility, and then try your API request with the encoded text.