0

I am getting the screeshot of the website. The problem is i have textboxes on the screen. When i take screen shot the values of textboxes are not appearing. Can someone guide me in rearranging the code. Thank you

protected void Button1_Click(object sender, EventArgs e)
{
    MailMessage msg = new MailMessage(txt_From.Text, txt_To.Text);
    try
    {
        msg.Subject = txt_Subject.Text;
        msg.Body = "<br /><b>form:</b> " + form1 + "<br /><b>From:</b> " + txt_From.Text + "<br /><b>To:</b> " + txt_To.Text + "<br /><br /><br /><br /><b>Name:</b><hr />" + TextBox1.Text + "<br /> <br /><b>Date:</b><br /><hr /><br />" + TextBox2.Text + "<br /><br />";
        msg.IsBodyHtml = true;
        WebRequest mywebReq;
        WebResponse mywebResp;
        StreamReader sr;
        string strHTML;
        StreamWriter sw;

        // Put user code to initialize the page here

        mywebReq = WebRequest.Create("http://localhost:4101/WebForm2.aspx");
        mywebResp = mywebReq.GetResponse();
        sr = new StreamReader(mywebResp.GetResponseStream());
        //sr = new StreamReader(mywebResp.GetResponseStream(), System.Text.Encoding.ASCII);
        strHTML = sr.ReadToEnd();
        sw = File.CreateText(Server.MapPath("Report.htm"));
        sw.WriteLine(strHTML);
        sw.Close();
        Response.WriteFile(Server.MapPath("Report.htm"));

        Attachment objAttachment = new Attachment(@"C:\Users\2714\Documents\Visual Studio 2010\Projects\Certificate\Certificate\Report.htm");
        msg.Attachments.Add(objAttachment);
        System.Net.Mail.SmtpClient objSmtpClient = new SmtpClient("10.238.52.200", 25);
        objSmtpClient.Send(msg);
    }
    catch (Exception ex)
    {
        throw ex;
    }    
}
Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208
user1665707
  • 615
  • 3
  • 11
  • 24
  • Are you trying to do somethin like this http://slodive.com/inspiration/showcase/50-captivating-horizontal-websites/? – Anuj Kaithwas Sep 22 '12 at 07:37
  • 1
    Why don't you print page as a XPS file and send that file through email? This might be a possible approach http://code.msdn.microsoft.com/CSASPNETPrintPartOfPage-afc45915 – radu florescu Sep 22 '12 at 07:40
  • I see that you print only the source file when it's rendered. – radu florescu Sep 22 '12 at 07:44
  • ya..but am stuck with how to get the values. – user1665707 Sep 22 '12 at 08:04
  • Are you trying to capture the output from the current page? If that's the case you can do that with some trickery... this might help: http://www.west-wind.com/weblog/posts/2004/Jun/08/Capturing-Output-from-ASPNet-Pages or this: http://www.west-wind.com/weblog/posts/2009/Nov/13/Capturing-and-Transforming-ASPNET-Output-with-ResponseFilter – Rick Strahl Sep 22 '12 at 11:43

1 Answers1

0

When you make a capture of the web page is logical to not see anything that the user have type on it - Actually is not exist, you just make a load of the page, what you expect to see on text boxes ?

If you try to get a report for debug reasons and you won to see what happens on the page at the moment of the issue then you need to use a javascript library that build (as he can) the dom of the page and send it to you. All this actions request the user to make them - to capture the web page and send it with email, even if you can make it automate, the user must deride if he like to show you what have type on them.

An example http://experiments.hertzen.com/jsfeedback/ and the library http://html2canvas.hertzen.com/ that can capture what the user see on screen.

relative : How can I convert an HTML element to a canvas element?

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • does iecapt also takes the screen shot of web page? I used it but even then the textbox values are not getting displayed. – user1665707 Sep 24 '12 at 09:23
  • 1
    @user1665707 I think that you did not understand the answer. You can not read the text box entered data from the server. If you can its easy to steal all personal data that anyone enters at any time. – Aristos Sep 24 '12 at 09:26