Showing an XML file in a form with C# - c#

it might sound stupid, but I need a way to take an XML file / string, and show it to a user in a form.
I'm currently trying to use the WebBrowser control, but its Document field is read only. I tried setting DocumentText instead but it seems to be accepting HTML only. What control should I use? It can be anything in WinForms or Infragistics.
Also, if there's a .NET XML parser, I'd love to know.
Thanks.

Give XmlVisualizer a try. Also you might want to take a look at the following posts:
http://www.dotnettutorials.com/tutorials/xml/winform-filter-xml-cs.aspx
Show XML file in WinForms app with IE-like coloring and collapsing nodes

Try setting the DocumentText instead. See this post for further details.

Load the document with XmlDocument.Load(). Then use XmlDocument.OuterXml...

Related

Editing HTML file online from ASP.NET website

I have an ASP.NET website that is a panel for managing and sending e-mails. I want people to have an editor to changed what is in the template itself (which is writing in plain HTML.) in withing my site.
But, I don't want them to see the HTML. I just need them to edit the text and not touch the CSS/HTML to not destroy the look of it. Any tips or solutions that any one may know?
Use a free RichTextBox control in your project. You can find many open source or free controls out there.
Here's an example
http://www.freetextbox.com/
In this website you could find a list of controls that you could use.
You can use Ajax "HTMLEditior" or "HTMLEditiorExtender" for this
purpose
For what is HTMLEditor and how to use it follow this link
HTML Editor (AJAX Tool Kit)
Check ckeditor which has lot of editing features and your users can do almost everything. Also it supports inline editing.

What to embed for a Richview Textbox with some formatting?

I have a webpage which has a textbox section in it. I want it to be similar like this image:
But not that much complicated regarding code files goes. Want the user to edit some characters put some Bold/Underline/Italic fonts into it. Some smileys that all.
Any help?
There are many great open source controls that do this free and easily. If you're using MVC, I recommend tinymce, or if you're using webforms, FreeTextBox is great.

Copying from WebBrowser Control

I have the following code in my C# windows app which places the data from my webbrowser control into the clipboard. However when I come to pasting this into MSWord it pastes the HTML markup rather than the contents of the page.
Clipboard.SetDataObject(WebBrowser.DocumentText, true);
Any Idea how I can get around this?
OK this feels like a dirty hack, but it solves my problem:
WebBrowser1.Document.ExecCommand("SelectAll", false, null);
WebBrowser1.Document.ExecCommand("Copy", false, null);`
Another option would be to capture an image of the page, rather than the html and paste that into the document. I don't think the WebBrowser control can handle this, but Watin can. Watin's (http://watin.sourceforge.net/) capturewebpagetofile() function works well for this functionality. I have had to use this instead of capturing HTML because outlook cannot format HTML well at all.
string allText = WebBrowser1.DocumentText;
will return you all currently laoded document markup. Is it what are you lookin for?
I guess that happens because what the webbrowser actually contains is the markup, not all the images etc.
You might be best to use the webbrowser to save the full page to disk, and then use word to open that. That way it'll all be available locally for IE to use. Just means you have to clean up afterwards though.
The link below has some stuff about saving using the webbrowser in c#
http://www.c-sharpcorner.com/UploadFile/mahesh/WebBrowserInCS12072005232330PM/WebBrowserInCS.aspx

Replicate Printed Form With Web Form

I'm hoping people have some ideas to help solve this problem.
I am developing a C# ASP.NET website and the client requires an online form that users will fill in and submit. OK, so far so good.....
Imagine, say, a form that you fill in on paper - they normally have a distinctive look specific to the company and will be filed, quite possibly as a legally binding document.
I need to have an online form that when submitted emails the client with something they can print out and will look exactly like their printed forms.
As this is web based, I think the option of capturing a screenshot are out the question, so I'm wondering how best to approach this?
Even if I just had a form that captures the data presented how I want, how could I translate this data into the view they want?
Any ideas and suggestions greatly appreciated.
You'll need to take the raw data that was submitted and import it into a standard document (likely PDF). You can use Crystal or another reporting solution, or direct to PDF using one of the many PDF .NET solutions that are out there.
I don't think you'd even want to deal with making the document physically match the screen - much easier to make the web look like the web, and make the printed doc look like a printed doc.
Print a page (this one) from a Browser, notice all the headers and footers?
If you want serious control over how it is going to look, you will need to generate a PDF (or maybe XPS).
Couldn't you just use a sepparate page with a CSS that gives the desired look & feel?

Best way to display multiple lines of static text in C#?

I am making a prompt in C# that instructs the user how to use the program before they can access it.
What is the best way to display multiple lines of static text? Using a bunch labels doesn't seem like it would be the proper way... xD
Use a text input box marked as read-only and multi-line.
If you're using WinForms, you might want to consider adding a WebBrowser control to your form - you can then point the browser to an html file you send with the program. This allows you to use all of html to instruct your users, as well as point them to, say, your web site for more help or information.
One label can contain multiple lines of text if the text has newlines in it.

Categories