View xml file in Internet Explorer from an asp.net page - c#

I am new to Asp.net. I have a grid view which contains text fields as well as three buttons. My system is generating the xml file and I want to view that xml file in a separate window. Say for example, my grid view contains 3 rows and there will be 3 xml files where one file will be associated with each row. So what I want is to view the file whenever I click the button in the corresponding row.
Can someone help? I know that I need to use some java script.

There are several ways to solve this. For an easy solution you could write the XML in the Response.
If you want a new window you could create a temporary XML File and redirect to its URL.
//create the XML and put it in the filesystem -- just use google
ClientScript.RegisterStartupScript(GetType(), "SomeNameForThisScript", "window.open('http://UrlToYourXML.xml');", true);

You have several options here:
You can stream XML, most morden browsers can render XML. Just need to supply style.
Use jQuery plugin like JQgrid, to render XML
Process XML on server side to convert it to HTML/Datagrid

Related

Sending HTML file with Images through email IOS

This is more of a general question about whether or not its actually possible to achieve what I want.
The basis is that my app allows the user to fill out various tables of data for a preventative maintenance check sheet. They can also attach images to this sheet which saves to the temporary storage on the IOS app. Once its complete they then press a button which generates a HTML document through a StreamWriter. Through this StreamWriter I have created, the images are also appended through URL references to the images in the temporary folder.
The HTML file (Generated Form) is then presented to the user using a WebView. Once the user has checked all the information, they then press a button which presents a MailViewController.
The HTML file (Generated Form) is then automatically attached and once the email has been entered you press send and everything works as it should.
The problem I am now having is that im not sure if its possible to keep the images in the html document. Once you open the HTML file on the receiving device, the images no longer loads because they no longer exist according to the HTML file.
So basically is it possible to keep the images in the HTML file once opened on the receiving device.
Sorry for the long description but its needed so you get an understanding of what I am actually doing. All the code I have written works as it should but just wanted to know if this is possible or not.
Thanks
Jamie
Use base 64 encoded strings for the images and it should work. Since the images would be passed along with the html

Saving data into files and reload them later

I am working on a WPF project with C#.
There is a MainWindow and some other windows showing some data. I have also three XML files, where data from lists can be saved. The code is all written and works perfect.
Now my question is, how to save the whole file. I want to have the capability to, for example, save all the data into files, and user can open these files later and load the data into lists, and commence working, where they left the application before.
Can anybody help me?
If I understand your question correctly, you need to do it with following steps:
Save your XML files with a specific extension name.
you can achieve this by many ways: e.g. you can save your actual XML files into a location, and then just create a link file that contents links to these files. Or you can ZIP all the XML files into one single file.
link the default extension name to your application (so it will be opened by your application by default)
Open/read the file with XML content from your application.
Check this
Deserialize XML into items and display them in your list.

Change blank fields in .doc file. WPF

I have a .doc document. In this document i have some blanks for data. For example:
"car_id" is the best car in "car_country".
I need to open this doc file and change this blanks ("car_id", "car_country") to data from some object.
How to do this?
I would use DocumentFormat.OpenXml.dll. You can find it here. OpenXMLSDKv2.msi will add assembly. You will just need to add reference to DocumentFormat.OpenXml. And the OpenXMLSDKTool.msi will install a usefull tool that will display xml structure of .docx (for example) document.
This web page has some very good samples of Word automation using C#. Specifically, look at section 6 in the web page for a Mail Merge example.
http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx

How to create *.docx files from a template in C#

I have a working ASP.NET MVC web application to manage projects and customers. Now I want to generate a word file for some customers. In this file should be displayed some data about the customer. Every generated file should have the same data and the same design. So I want to craete a new Word Template with the fields and want to fill the placeholders programmatically.
My problem is that I couldn't find a clear way to do that. Does anybody know a good learning resources?
Try this page:
Building Office Open XML Files
Open XML files (docx) are ZIP packages containing XML files. In your case, I would create a copy of your original template, then use the System.IO.Packaging API to open the file and modify it. By opening, the correct XML file and replacing certain placeholders in XML, you should be able to achieve the result you want.
While trying to do the same I have found some libraries to create/edit DOC or DOCX in .Net
GemBox.Document
TemplateEngine.Docx
DocXTemplateEngine
Templater - Nuget
Spire.Doc - Nuget
for the new document generation from a template file (.dot) should be very easy, I think it's a parameter you specify in the word application file open or so, when you pass the path of the .dot file, telling word to create a new .doc based on that file and not edit the actual template document.
for form fields and bookmarks filling, lots of examples online on how to do it from C#, see here:
MS Word Office Automation - Filling Text Form Fields And Check Box Form Fields And Mail Merge

forms as html and pdf

I would create many forms with different outputs but i wish to design the form only once.
First - HTML:
the form must be displayed in
Internet Explorer
the values (the user fills out the
form) must be saved in a database
the form must be displayed with
the previus saved values in Internet
Explorer
Second - PDF:
the form must be exported as pdf
with the previus saved values
Requirements:
desing the form only once
display+edit as html
display as pdf
Optional:
support for javascript on client-side
for validation
I'm not sure whats the best way.
I could use libarys/tools like wkhtmltopdf or dompdf but i'm not sure if whether this also supports filled out html-form.
Imo XSL, XSLT and XSL:FO isn't an option because, if i understand that right i must create an XSL:FO for HTML-Output and one for PDF-Output.
What does you think?
I don't know if it could be useful for all your points, but Crystal Reports files (.rpt) can be filled then exported quite well to Pdf, html or Word. It can take some time to get it working though (at work we use the version integrated in VS2008)...
Have a look at Stimulsoft.Web gels a lot with C# and you can export to anything + you can buy the sourcecode also,less expensive.

Categories