Saving file using WebBrowser control
-
I am using WebBrowser control and I want to save the loaded page from my application. I am using following code. webBrowser1.ShowSaveAsDialog(); This shows save dialog box but after that I want to add code whether user has clicked on Save or Cancel button. This method returns void so I am not able to decide what happend after showing dialog box. Can any help ? Thanks.
-
I am using WebBrowser control and I want to save the loaded page from my application. I am using following code. webBrowser1.ShowSaveAsDialog(); This shows save dialog box but after that I want to add code whether user has clicked on Save or Cancel button. This method returns void so I am not able to decide what happend after showing dialog box. Can any help ? Thanks.
try using httprequest if user is not logging in or filling any data on form. HttpWebRequest req = (HttpWebRequest)(WebRequest.Create(PostUrl)); req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)"; req.Method = "GET"; req.KeepAlive = false; req.Timeout = 1000000; req.Proxy = WebProxy.GetDefaultProxy(); req.Proxy.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse res = ((HttpWebResponse)req.GetResponse()); StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.GetEncoding("iso-8859-9")); result = sr.ReadToEnd();
-
try using httprequest if user is not logging in or filling any data on form. HttpWebRequest req = (HttpWebRequest)(WebRequest.Create(PostUrl)); req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)"; req.Method = "GET"; req.KeepAlive = false; req.Timeout = 1000000; req.Proxy = WebProxy.GetDefaultProxy(); req.Proxy.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse res = ((HttpWebResponse)req.GetResponse()); StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.GetEncoding("iso-8859-9")); result = sr.ReadToEnd();
I believe the WebBrowser class also has properties .Document and .DocumentText see this: http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.document(VS.85).aspx[^] as well as: http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documenttext(VS.85).aspx[^] in the past for simple stuff I've just saved off the .DocumentText stuff to a file since I was just populating simple html to the control; but whatevers clever for you.