0

I am using .aspx page, i want to save some data on button click, which i extracted using function

 function save() {
            var t1 = document.getElementById('test').innerHTML;
            alert(t1);
        }

to .text file, .html file some folder on desktop. the folder should appear, where i can save the file with any extension of .text or .html.

NoviceToDotNet
  • 10,387
  • 36
  • 112
  • 166
  • TJHeuvel:- i want to save a particular portion of page as an template to the folder, that need to re attach on template selection to the same element. – NoviceToDotNet Nov 03 '11 at 14:07

2 Answers2

3

Javascript in the browser has no file i/o capabilities. The best you can do is popup a window with just the text you want to save and then save using the browser or send the text to the server and have it serve up the appropriate download mime-type as a new page.

JaredMcAteer
  • 21,688
  • 5
  • 49
  • 65
  • But i want to save it to desktop folder with user choice extension, like .text or .html. that he can re-add to save element on template selection from the folder to the same element, where i extracted this data from. – NoviceToDotNet Nov 03 '11 at 14:09
1

You can't with javascript. You'll have to send the data file server side. See C# Asp.net write file to client.

Community
  • 1
  • 1
jrummell
  • 42,637
  • 17
  • 112
  • 171