I've encountered a problem with html special character conversion when the jqxeditor is bound to a model for the message. Once that model is saved the partial view is reloaded and any greater then or less than symbol is not displayed, but rather <>
This happens whether the data is changed to <> or left html. The original text area shows < > when it does not have the jqxeditor applied to it.
I saw a problem similar to this at:
How to stop converting “greater than” and “less than” symbols to entities in Rich Text Editor?
I've also tried loading the value through javascript val, instead of automatically binding it using asp-for
The work around I found was to replace the   & < > on the controller that accepts the form post and put. Those values are stored with html markup for everything else except the specified characters in the database, which is in turn given to the jqxeditor without indicating special characters. Also, the message displays with no issue when the message is viewed.
So far, so good. However, I'd rather have the jqxeditor display those characters from the HTML markup when loaded either from the model or from javascript.
What am I missing?
Related
I'm making a detail page about certain items.
This detail page can contain large blocks of text, and the customer would like to only show the first 100 letters and then put a " ... more " at the end.
When the user clicks this " ... more " the rest of the text can be shown.
Biggest problem: the text is currently is a CMS and has large varieties. Some is pure text, some have html elements in them ...
I tried to cut off the text and put them in spans. Then i could show/hide these spans as i please. The issue here is that there can be a starting element of a certain tag in the first span and the closing element can be in the second span. This causes the DOM hierarchyto be faulty and the result is never pretty.
Does anyone know a ( other ) way to achieve this or a library i can use ?
To be able to extract "readable" characters you need to get the content into a plain text format (get rid of the mark-up).
Since the content is stored in a cms it is likely that the content is structured to be well formed - thus xhtml.
If that is the case you can treat the content as XML. Get the root node and get the innertext property there-of. Then you will have plain text - no tags - and can easily cut it after the first 100 characters or whatever the requirement is.
Hopefully the content doesn't contain js/css!
Edit:
It seems that the markup must be retained.
Try the following xsl to transform and truncate the content:
https://gist.github.com/allen/65817
I have an XML file storing a string like the following:
Error: The form's name field was left empty!
Now, this message in the XML file is used in various locations. For instance, it is sometimes bound to an aspx control and sometimes displayed in a JavaScript alert.
In order to escape the single quote character, I modified the message as follows:
Error: The form\'s name field was left empty!
When the message is shown in a JavaScript alert, it is displayed as it should with the single quote escaped. However, when it is bound to an aspx control, it is displayed as is.
I tried modifying the message as follows:
Error: The form's name field was left empty!
and
Error: The form‘s name field was left empty!
With these two cases, the message displays as it should when bound to an asp control. However, when passed to a JavaScript alert, I get the ") expected" error in IE8.
How can I get this to work for both aspx controls and JavaScript alerts please? I have already wasted a lot of time on it. Thank you so much.
N.B. I am using a very old version of the .NET Framework, specifically 2.0.
You should just store your messages verbatim and then let each client handle the special character. So, store as Error: The form's name field was left empty! and then within each language add a step that checks for special characters and escapes them accordingly.
I have some text currently stored in my database table as nvarchar.
I am currently retrieving the text using a stored procedure and binding it to a literal within a gridview on the front end.
What I would like to do is to retrieve the text and then format it , like inserting line spaces and making
certain area bold. Is it possible to do so ? Can anyone give me an idea of how it can be done ?
One idea thats striking me is to use XML while storing the text . But even if I do that how would I make a certain part of the text bold and include line spaces.
So currently, my text is stored in the database table column nvarchar(max) as:
This is the heading this is the content
What I would like to do is to display the above within a gridview like:
**This is a Heading** (heading in bold)
This is the content
The simplest method (one I have used several times) is to store the html in the table like this:
<h1>This is the heading</h1>This is the content
You will have to add special handling for working with html, but it works just fine.
You can also store the header string in one field, and body in another.
Short of that, you would have to have some indicator telling the front which part of the string should be bolded, etc. and that can get very complex
Short answer is that this is possible but takes some work.
You first need to decide in what format are you going to store the data and how can you specify format on the client side, before text is entered into database.
If you have WYSIWYG editor for text – html conversion you can try storing the HTML. This will be the easiest way in terms of storage.
If you decide to use this method note that you’ll need to do a lot of validation on the server to avoid cross site scripting attacks. Shortly put – make sure the HTML you get on the server doesn’t contain any javascript or any tags apart from those you want to support.
Its better to use Editor of AJAX Toolkit, doesnt required any other thing, its a complete editor, you can even color your font as u wanted.
In my asp.net web application, i have used liter control for displaying HTML data.Whenever user clicks the button, i will have a set of html data and needs to display it in the literal control.
Suppose if i have HTML table data or any other text with some formatting tags then it also displayed in literal control perfectly...
But i have a problem with displaying this HTML TABLE data(particularly this). for example, i have this HTML TABLE data in string.In debugging mode i just copied the string value and stored it as .html file.So, If i open the file in browser it shows the full table data(Way 1).But in my project, i just assigned the string value to literal control text.
literal1.text=htmlString;
But i when looked at the browser, my literal control shows only from part of the html table data.particularly,the first column is fully not shown and also part of the second row is not shown(Way 2).
I little bit doubt about whether it is a alignment problem.I can't able to set the alignment of literal control anyway...
Please guide me to get out of this issue...
I have attached print screen of the both original table data displayed in browser(Image 1) and also literal control table data(Image 2)...
* Image 1 for Way 1*
* Image 2 for Way 2 *
The first thing I'd recommend is to compare the resulting html markup and affecting CSS using Firebug or another web developer tool. That should tell you where the differences are.
Based on your screenshots it looks as though the difference comes down to styling so either your HTML differs from one version to another and/or the CSS.
Can you post some code to go with your question?
I am new to C# and was experimenting with the ASP.Net GridView (framework 3.5), and I found out a big problem when the gridView text contains the following:
ñ/Ñ/á/Á/é/É/í/Í/ó/Ó/ú/Ú or a â, ê, î, ô, û, ë, ï, ü or even a ç
The results end up displaying something like this: &+#+237
I made a mixture of pain by doing a table,dataset etc... to get the data from the database clean as the letter itself. I also tried making a method that cleaned the variables but it was a terrible IF.
I was wondering if there was a way to make the letters appear as themselves (ñ as ñ not as &+#+237) when extracting data from the gridview without getting the data directly from the database and without doing a lot of code. If there is not, is there a way to code efficiently clean them up?
Your characters are being HTML encoded, either somewhere in your data access layer, or within the gridview controls. Try running the text through HttpUtility.HtmlDecode() before binding the grid.
If that doesn't work, then it's probably being encoded at the control level. I see that you tagged this question with "textbox". The standard ASP.NET TextBox control will automatically encode anything that's assigned to its Text property. Instead, you can use a generic System.Web.UI.HtmlControls.HtmlTextArea control or new HtmlGenericControl("input").