Open and edit XML file in web page - c#

Using ASP.NET and C# I'm looking for a way to open and edit an XML file via a web page. A user needs to go to a web page, open an xml file that is stored on their local machine, and then make edits and save it back locally.
I'm not sure how to open the file. Do I use the FileUpload control to let the user browse to the local file and then on a button event load the file into an XmlDocument? I tried this and could not get it to load the file. Once I have the file loaded I think I can build/edit nodes and data.
Not sure how to then save it back to an XML file on the local machine again.

If you want to do this in an ASP.NET web application I see the following process:
1) allow users to select a local file from their machine and then upload it on server and show its content in an edit box ( here you could also do nice things like allow drag and drop from windows explorer, there should be some JQuery / JS components ready out of the box to provide such feature );
2) once the file content is shown in the web page in a multi-line textbox ( ideally you would like to provide syntax coloring etc using specific web controls ), users can edit the content of it;
3) after changes are made, clicking on a save button the web page will start the download of the file from server to client, you can download the file with same name as it was uploaded if you stored that name somewhere, users will decide where to save the file.
This is the way I understand/see you can provide a functionality similar to what you have described from the top of my mind.

Related

How to Display a word or anyother Document into asp.net page without downloading from sharepoint

my project is a finance based website,
now when ever we upload a word,PDF or Excel document the file is Directly saved in sharepoint and a link is provided to user or the the person whom he submits the invoice or application but according to the new requirement we should provide a view button that basically display the content to the file Kinda like opening a word file on Gmail or yahoo..!!,
as far as i know to open them the file must be physically be on the server to be opened by viewer but the file is uploaded in Sharepoint directly as mentioned earlier
and i can't write any code for the file to be downloaded on server or on client machine coz
reason 1: File may be to Large
reason 2: Performance will be reduced
so is there any other way i can open that respective file in a viewer or popup without downloading it on server or on client machine
Please help me on this
Thanks
If I understood your question correctly , you want view the file in browser ?
Use Office Web Apps with SharePoint
Install office webapp
Activate it

c# Open and write to external browser from windows form

I have a C# Windows form application and I need to open a a webpage that sends SAML off to a server with then does auth and redirects to the destination. Since the SAML I am writing/sending changes every time, I've been writing a simple file to the temp folder and opening it via the default browser. Internet Explorer doesn't like doing this and balks saying the content is blocked.
Is there any way I can, from a Windows form, open an external browser and write content to it?
I added
<!-- saved from url=(0016)http://localhost -->
in the html file I'm opening from the local temp folder and now IE opens it just fine.
Answer found from
Why does IE restrict the JavaScript files of local HTML pages?

Custom action send document to different page

I have a SharePoint 2013 provider hosted app. In the app project there is a ribbon custom action that navigates to a page in the web project. When the ribbon custom action is pressed, the selected document (the entire document not just properties) should be send to the .aspx page. On the .aspx page I want to save it in the database.
How can i send the entire document to the .aspx page?
<CommandUIHandler Command="Invoke_RibbonCustomAction1ButtonRequest"
CommandAction="~remoteAppUrl/Pages/CustomActionTarget.aspx?HostUrl={HostUrl}&Source={Source}&ListURLDir={ListUrlDir}&SelectedListID={SelectedListId}&SelectedItemID={SelectedItemId}"/>
</CommandUIHandlers>
This is the code I have but as you can see this will send the properties to the .aspx page and i want to send the entire document.
Through Source={Source} you can get the complete url till document and when you hit it you are able to download it. so i guess you have to write code on another page from where you want to push it to DB, download it on local and from where you can push this file to sharepoint DB.
i am not able to fully answering your question but hope it may give you some directions.

Use google doc API in asp.net C# web application

I am developing a web application in C#.net. I need to edit a file placed on the server in browser it self(Without downloading it on local machine) and when I save that file, the changes should be reflected in file. For this I want to use google API but I don't know how can I use this.
I want to do like below.
When I click on file name, it should open in browser.
When clicked on edit, it open in edit mode in browser using google doc.
When I save that file, the changes should be reflected in my file which is placed on company server.
How can I do all this thing with google doc API?
Install Google Drive on your server.
Edit the file in Google docs, let Google Drive sync it to the local hard drive.
It is not possible for HTTP protocol, because the basics system doesn;t support it. You can open the file but the file will be downloaded to your local machine in then it will open, you have to specify the MIME type in IIS.
You can use two ways to do a similar job done.
1 By Using FTP
2 Customized solution : Make a page put a text field and load the file (.cs) in it and with submit save it to the file back.
You can embed a google doc in Webpages. But the file would be accessed and saved on Google's servers and not your company server:
Wordpress allows you to do it. Potentially you can see if it possible to do it in a similar way:
http://en.support.wordpress.com/google-docs/
I am not sure if Google has an option of accessing docs from servers outside google's domain.

WebForm (INtranet) app - Prompt user the where to save file and use as default

I have a WebForm application that generates a Crystal Report and streams it to the browser as a PDF.
My users would like the app (well, the Browser I suppose!) to always prompt them where to save the file (a network path) and then store that path (probalby in the SQL table that stores their profile info) and always use that path as the default on subsequent attempts.
I am pretty sure I know how to force the browser (IE) to always prompt them where to save the PDF or open it, and I can name the file (attachment), but how can I automatically populate that dialog box that appears (when thy choose to save the file) with a path? Is there some other way I can accomplish this (use a different mime type or something?)?
I suppose instead of streaming the file back, I can just prompt them for where they want to save and (with elevated permissions on the App Pool Identity) save it out to that path from the server. Since this is an Intranet application, the App Pool does already have some elevated permissions, because it must check certain network paths to see if files exist (it is also a Change/Revision app for CAD Math Data files).
How would you handle it?
You absolutely can not force the web browser to choose any particular location by default to save files, without third-party plugins (most of which I hope would also similarly prevent this sort of thing, which could be used for Evil)
So, if the server has access over the Intranet, that's how you'll have to do it.

Categories