-1

Am trying to convert aspx page to image i.e save it as a png file. I used iecapt for this. I have many textboxes on aspx page. The problem is the textbox values are not saved in the image file. Am just getting the source file image. Hope i get some suggestions on this. Thank You

protected void btnsend_Click(object sender, EventArgs e) {

        string url = "http://localhost:4101/WebForm3.aspx"; 

        if(Request.Params["weburl"] != null)
        {     
            url = Request.Params["weburl"];      
        }               
        string savepath = String.Format("C:\\IECapt\\{0}.png" , System.Guid.NewGuid());    
        System.Diagnostics.Process process = new System.Diagnostics.Process();   
        process.StartInfo.FileName  = "C:\\IECapt\\IECapt.exe";
        process.StartInfo.Arguments = String.Format("\"{0}\" \"{1}\"",url,savepath);
        process.StartInfo.UseShellExecute = false;  
        process.Start();    
        process.WaitForExit();  
        process.Dispose();  
        Response.Clear();
        Response.ContentType = "image/png";
        Response.WriteFile(savepath);
        Response.End(); 
    }
user1665707
  • 615
  • 3
  • 11
  • 24
  • You try the same as this one, but with images http://stackoverflow.com/questions/12342519/how-to-play-sound-by-clicking-button-in-asp-net – Aristos Sep 24 '12 at 09:34

1 Answers1

1
The problem is the textbox values are not saved in the image file.

Of course they not, if they do then every one it will be able to read out entered data - but also this is not the case, the case is that the page that you load did not contains any entered data - is one isolate load.

When you do that you thing that you load what user see, but actually not, you not see what user see, you just make one more load of the page.

You must distinguish between the code that run on server and the code that run on client browser.

You ask also the same at: Screenshot of webpage in asp.net c#

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • ok..i got it.. but is there any way to save aspx page as an image along with textbox values? Coz i need to send that image file via email and the recepient must be able to download it and print. – user1665707 Sep 24 '12 at 10:37
  • @user1665707 I have told you that on the previous answer. Look at that examples: http://experiments.hertzen.com/jsfeedback/ Click the button on the bottom right – Aristos Sep 24 '12 at 11:18
  • Thanx for the suggestion but am not able to download htmltocanvas as its blocked. So was trying other approaches. Can i send a div as body of the email. My div has all controls. – user1665707 Sep 24 '12 at 11:36
  • @user1665707 I do not understand what you talking about. Is not blocked at all, I just download it. https://github.com/niklasvh/feedback.js There is not other approaches, and you are lucky that this lib exist :) – Aristos Sep 24 '12 at 12:12