I have tried to use the standard AJAX HTMLeditor from here (http://www.asp.net/ajaxlibrary/act.ashx) and I have try to work with the FCKEditor (from http://ckeditor.com/)
But both don't do everything. I call the AJAX standard control A and the FCKeditor F.
With the A editor it is impossible to get your HTML text in the HTML content. You can only get it in the Design content. (this next code doesn't do the job: string htmlContentStr = Editor1.Content).
With F it is possible to get it in the HTML content (it does this by default), but to get your changes back in HTML is impossible. (this next code doesn't do the job: string htmlContentStr = FCKeditor1.Value).
So what I need is a HTML editor that is possible to put HTML text in HTML content, a user can make changes in the designcontent and after the changes 're make it must be possible to get the HTMLcontent and put it away in a string or database.
Is this possible or do I need a commercial one to get this feature?
If my question isn't clear, please let me know.
Thnx
I've used XStandard quite easily and it let me manipulate the HTML. I didn't bother using it as a control, but just read and wrote (escaped) the HTML where needed into the asp output.
Related
Does anyone knows how to implement razor syntax to be rendered when using CKediotr. I want to enter c# code in CKEditor but Im not able to do that because it renders all content as a text.
Sample:
I want to enter e.g. #DateTime.Now.Year inside ckeditor.
and other more complex types.
Thanks,
TinyMCE, (F)CKEditor, et al are HTML editors, and are not designed for C# (or PHP, ASP, CFM...) functions. While you could possible right something for evaluating the text and figuring out what you need to do, it becomes a royally complex PIA. There are two ways that I have seen that work with decent results.
The first method would be to have the output from your (CK) Editor saved as a partial view, and then calling that inside of a parent view. The problem with this method is that if someone who does not know Razor makes an error it will kill the page. Same thing occurs for other programming errors.
The second method would be to create placeholders for common items, and then doing an evaluation method for replacements.
string BodyContent = GetPageContent(PageID); // whatever to grab CKEditor content
BodyContent = BodyContent.Replace("##Year##", DateTime.Now.ToString("yyyy"));
// other replacements here
And then on the view you would just call that variable accordingly. It is limited as to what you can do, but that isn't always a bad thing.
I know that there is lot of reports that DocumentText isn't changing but Document.Body.innerHtml is.
I'm interested only in simply solution how to change it other way than ordinary string (replacing substrings). Is there a possibility to use getElementById().innerText ?
I want to open html file, make changes in and save it.
There seems to be a problem with the ASP textbox control when set to multiline and serving the page as xhtml. The project I am working on uses content negotiation to serve asp pages as application/xhtml+xml to browsers which support it. The problem is when asp textbox renders a textarea to the page, it explicitly prepends a newline to the text. Reflection of the textbox's render method looks like the following:
if (TextMode == TextBoxMode.MultiLine)
HttpUtility.HtmlEncode(Environment.NewLine + this.Text, (TextWriter) writer);
When firefox and opera are served this with xhtml content type, they interpret the newline as part of the text in the textarea and so I get extra newlines at the beginning of my text areas.
I could subclass textbox and override render, but that seems like a bit of overkill to correct something like this. Is there another way to correct this? And does anyone know why asp textbox does this anyway?
An alternative to subclassing is to use control adapters, or to write the <textarea by hand and get ASP.NET to generate the control name attribute for you.
I suspect ASP.NET WebForms does this simply because of a short-sight. The future is MVC anyway, so don't expect this to be changed any time soon. I suspect the original purpose of the newline is to give the textarea a "value" rather than nothing (thus making the textarea "successful" in HTML forms parlance).
This isn't the only odd behaviour you'll see in ASP.NET. The atrocious HTML formatting of <head runat="server"> is also on the list.
On my master page (for all pages in my site) I have a ToolkitScriptManager.
On my content page, there are a series of hyperlinks and divs for collapsible functionality.
The code to show/hide the panels work like the following:
$(document).ready(function() {
// Hookup event handlers and execute HTML DOM-related code
$('#nameHyperLink').click(function() {
var div = $('#nameDiv');
var link = $('#nameHyperLink');
if (div.css('display') == 'none') {
link.text('Hide Data');
div.show('100');
}
else {
link.text('Show Data');
div.hide('100');
}
});
});
If I include a ScriptReference to the jQuery 1.4.2 file in the toolkitscriptmanager, the javascript code is executed incorrectly on the page (only the text for the hyperlink is changed, the div is not actually shown.) However, if I don't include the jQuery file in the ToolkitScriptManager and instead include it in the content page, it works correctly.
I'm a Javascript/jQuery newbie, and this makes no sense at all. What's going on here?
Positioning of the script include is important for the jQuery ref. If you look at your generated source I would bet the tag is below the script function(). You should make sure that the jQuery reference comes as early as you can get it in the page source.
Try moving the jQuery library reference into the head of your master page, that should work. Otherwise post up some source!
Like Tj says... should probably be in the head section of your master page. Also, it's nice to link to Google's version of this library, because chances are your users will already have it cached. For instance, look at the source for this very page.
The two most probable causes here are $ not being defined yet (see Tj's answer) and $ getting defined by another library, such as prototype.
I would highly suggest you look into using Firebug's javascript debugger, or at least take a look at Firefox's built in error console (Tools -> Error console). That will give you a much better clue what is going on other than "it's not working."
I have some XML in an XmlDocument, and I want to display it on an ASP.NET page. (The XML should be in a control; the page will have other content.) Right now, we're using the Xml control for that. Trouble is, the XML displays with no indentation. Ugly.
It appears that I'm supposed to create an XSLT for it, but that seems kind of boring. I'd rather just throw it into a control and have it automagically parse the XML and indent correctly. Is there an easy way to do that?
You could try to use XmlWriter/XmlTextWriter, set the writer's Indentation property, write to a StringBuilder or MemoryStream, and output the result inside a <pre> tag
A quick (and dirty) way of doing this would be to use an IFrame.
In truth, an XSLT is the "ideal" way for formatting an XML for display. Another option would be to parse it manually for display.
To use an Iframe:
ASPX side:
< iframe runat="server" id="myXMLFrame" src="~/MyXmlFile.xml" /></pre>
Code Side:
myXMLFrame.src = Page.ResolveClientUrl("~/MyXmlFile.xml")
You can find a slightly modified version of the XSLT that IE uses to transform XML to HTML when viewing in IE at http://www.dpawson.co.uk/xsl/sect4/N10301.html#d15977e117.
I have used it in a WebBrowser control in a WinForms application, and it works lika a charm. I have not tested it in FireFox/Chrome/Safari/Operat, though.