I created a web page in ASP.NET 4.0.
I'm using MarkdownDeep library (http://www.toptensoftware.com/markdowndeep/) to convert some text to HTML.
I found an issue that I can't fix. I hope you can help me.
I have some kind of forum, a want to post some code into the comment and see the indentation.
In the markdown preview editor, the text looks good. I save the textarea content to a database I show in the page, and I looks good.
For example, I try show two element tags of html to see the indentation on the code.
If I see the code with Chrome Development Tools, I look this:
<pre><code><head>
<title>
</code></pre>
It shows like this:
Everything is fine. But, if I reload the page, it appears like this
<pre><code><head><title>
</code></pre>
And it shows like this:
What I'm doing is:
write some text in the textarea
save text to the database
bring text back from database
converting markdown to html with the Transform() method of MarkdownDeep
put the result to the a Label's Text property
I tried, converting markdown before saving to the database, but nothing changes.
Ok, I finally found the solution.
That code was in a page that have a masterpage. If I took away the masterpage, everything is fine.
I don't know why... but that issue dissapear.
Related
I've searched the web for 2 days now and am about to give up on this, but I'm soo close to the final solution... so you're my last hope. ;)
I have made a little C# application with Windows Forms GUI that uses a webBrowser element to display an HTML file with a TinyMCE editor embedded - this way I get a nice window with customizable editor functions I can use perfectly for my needs in this project.
I can set the textarea input for this editor window without problems thanks to this solution posted here on stackoverflow: https://stackoverflow.com/a/16322324/3498545
However I'm having big troubles reading text from this textarea. If I read the element by ID as shown (for setting content) in the solution above, I get the old text, as TinyMCE never really saves the changes.
But how do I get the input that my users will make in the textarea via TinyMCE? Is there some way to trigger a form send in HTML to get this input?
Thank you so much for you help!
Ok, to answer my own question (maybe others find this useful sometime later):
The changes of TinyMCE don't get written back to the textarea field in realtime, so I had to work around that. One solution would be to add something in the javascript header that writes every change back to the textarea immediately, however this caused problems for me as TinyMCE code clean up is not involved at this point.
My solution was to temporarily create a new file where the input of the TinyMCE field gets written directly into source code, which is a piece of cake to read back in C#.
The javascript code needed looks like this:
setup : function(editor){
editor.on('submit', function (){
tinymce.triggerSave();
document.writeln("<!DOCTYPE html><html><body><div id='content'>"+document.getElementById('textarea').value+"</div></body></html>")
document.close()
});
}
After that you can read the content in C# with the following code:
webBrowser.Document.GetElementById("content").InnerHtml
Now I can store HTML formatted code in my SQL database that can be managed and edited with a shiny interface. ;)
I need to generate some data on the fly (when a user clicks a button on an .aspx page) and send it to the browser as a Word document.
I found this article and copied the code. At first it worked perfectly. I made some mods to the code to get it to do what I want and suddenly I found that when IE displayed the box in which it says 'Do you want to open or save MsWordSample.doc(3.77k) from localhost' - when I click 'Open' - it shows initially '100% downloaded' but this disappears (very quickly - you barely get to read it) and is replaced by text that says 'MsWordSample.doc couldn't be downloaded'. If I click 'Retry' it opens Word but it displays a representation of the .aspx page. I.e. it shows the text box and label - it doesn't show the html which is in the Response.Write at the end of the code.
How can this happen? First off it worked fine. I have changed the page back to exactly in the sample code - but it still won't send the right data to Word - it, (after the messing around described above) opens the code on the .aspx page.
Please try something like Response.flush() and Response.End() at the end of your code.
I am facing a pesky problem at the moment on a large website with multiple languages. On arrival at the website, it detects what country you are from and prompts you to confirm this. On confirmation, it swaps out the pages languages from the DB and displays the relevant language. This is done using jQuery. Now the problem is that Arabic reads rtl, so I need to either:
-- swap out the stylesheets for "rtl" version
or
-- change the HTML tag and include a "dir='rtl'" arrtribute
Now, I have tried both of these, with failures on both. When I view the page source, it still shows the old Css file or HTML tag without the "dir" attribute. Correct me if I'm wrong but I believe this to be due to the DOM not registering the new changes, as they have happened asynchronously via jQuery after the DOM has been instantiated.
After all that blah blah and tldr;
Is there not an easier way to swap out the text direction dynamically? If this is a DOM issue, how can I reload the DOM after the asynchronous callback?
I have been at this issue for hours now and have had very little luck on the interwebz.
Any and all help is welcome and greatly appreciated.
Kind Regards,
William Francis
EDIT:
After much investigation I found that the only way to truly work the Arabic way is with a post-back. Once the language has been selected you do a postback, then its just a simple process of changing the Stylesheet HREF attribute from code behind. There doesn't seem to be any form of JavaScript or jQuery that can change it without a post-back and still reflect the new Stylesheet. NOTE: you need to set the Stylesheet HREF on each post-back, i.e. through a master page. The Stylsheet changes do not persist across pages.
Here's a website that helped greatly and explains a whole lot on Stylesheet changes using JavaScript. sadly, it didn't work for me.
http://www.alistapart.com/articles/alternate/
There could be several things going on. I found this page to be very helpful when I was dealing with a similar thing, so I highly recommend it:
http://www.w3.org/International/tutorials/bidi-xhtml/
Also, if you aren't already doing so, use a tool like Firebug to examine the generated DOM after your AJAX has run to be sure you are seeing the altered state of the DOM and not the initial source of the page. It is possible to change the dir dynamically--you can use Firebug to add a new attribute to the HTML tag of this very page (set dir="rtl") to see it change dynamically. It could be some other element is overriding the direction, it could be that the AJAX changes aren't loading correctly, or other things. If you can post more of your code it would be helpful to give a better answer, but I hope this will help.
Before you jump all over me, I know about the SaveToString() method! The problem is that it only grabs the server-returned HTML. If it's further processed through script, I don't see a way to get at the actual rendered HTML. An easy example is a Tumblr page. If you view the SaveToString source on the phone you get a minimal link to the RSS feed and few other tags. Try to view the source in IE or Chrome and you'll see the full (and long) HTML. Any scripting call would replace the HTML, and there don't seem to be any other relevant methods. Any thoughts or ideas?
Had a look into Javascript?
Calling JavaScript Functions in WP7
should do you just fine
I am working with .net c#.
Is there a way to see the rendered html code under the updatepanel?
Thanks
more info:
I dynamically generate UI controls and place them in a asp:Panel control I have under updatePanel. My page is initially almost empty, and I add about 50 new controls upon button click. However, I cannot see the html code generated in the page source. as in, I can see my textfield on the screen but I cannot see the corresponding code in the html source on my browser.
Thanks again.
What are you using to view the source? If you are using the View Source functionality in some browsers, this may only be showing you the initial server response, and anything dynamically inserted into the page in an AJAX call might not appear.
If you use a tool like Firebug you can watch the current state of the DOM, which will show you any dynamically inserted elements.
With Internet Explorer you can use the Developer Tools (IE8) to view the actual source, not just the initial source. As Tom said Firebug will do the same thing in Firefox, and Safari has a similar option that I can't remember off hand what it's called.
Basically, you need to inspect the DOM instead of the html source. Addins like Firebug for firefox and Developer Tools for IE8 would allow you to inspect the DOM and even allow you to update them dynamically.
If you need to view HTML instead of the DOM representation, you can use Fiddler or Firebug's NET Panel, which will let you debug HTTP traffic and see the response given for the AJAX calls.
It does appear over here, just like normal ASP.net controls, just there is a little bit of ajax code that does the updating. Can you be more specific about what are you looking for?