Page load captcha not load in webbrowser - c#

I am using webbrowser into Windows application.
When webbrowser navigate first time, there is no problem.
But calling second time webbrowser navigate captcha does not change.
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("uyg.sgk.gov.tr/SgkTescil4a");
webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.AllowNavigation = true;
}

To prevent page caching on your client, which may be the reason why you see the Captcha not changing use
webbrowser1.Refresh(WebBrowserRefreshOption.Completely).
to clear the cache. If its not a client side caching issue, then its a problem with the website.

Related

WebBrowser does not change

I'm making an application in C# which, depending of a variable, shows one web page or another.
When I push a button, the program load the userName and the webBrowser should show a different web page. Here is my source code:
private void button1_Click(object sender, EventArgs e) {
string url = "http://www.url.com/" + userName;
webBrowser1.Navigate(url);
webBrowser1.Refresh();
}
The problem is that, when I push the button a second time with a different variable, the web browser reloads the same web page.
I think it's because of the webBrowser1.Refresh(); you don't need it and i think you are pushing the button 2 consecutive times with different values and it gives you the impression that it's loading another page but it isn't. try to remove that line and add an event to the Navigated method of your WebBrowser object in order to obtain a feedback when the browser is done loading the page.
I have solved my problem. I had set the property AllowNavigation to false, so, when I tried to change the web page, it didn't allow me to did it. Anyway, I needed to remove the Refreshcall to make it work.

Windows Phone 8 SDK - WebBrowser Control - How to refresh page from code

How can I refresh the webbrowser control from the code behind?
I am using Windows 8 SDK & C#.
You can accomplish this by storing the most recent visited Url then when you need to refresh you just navigate to it.
private void browser_Navigated(object sender, NavigationEventArgs e) {
lastUri = e.Uri;
}
private void Refresh() {
browser.Navigate(lastUri);
}
You could do this via injecting JS into the page via the browser contr:
var js = "window.location.reload(true);";
Browser.InvokeScript("eval", js);
Would be this way;
Browser.Navigate(new Uri(Browser.Source.AbsoluteUri));

Opening Web Browser click in default browser

Currently I am building a windows form app using c#. I have a web browser control on my form that displays a google ad. When clicked the webpage is displayed within the little 300x300 web browser control on the form. Is there a way for me to launch the default browser when the ad is clicked instead?
Thanks.
Edit: I figured out I can do so open the default browser by using Process.Start("url here"); but the browser windows is opening upon app load.
Edit Adding Code:
Form.cs
private void AdPanelNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
e.Cancel = true;
if (e.Url != null ) Process.Start(e.Url.ToString());
}
Form.Designer.cs
this.AdPanel.Navigating += new WebBrowserNavigatingEventHandler(AdPanelNavigating);
You can add Navigating event handler:
webBrowser1.Navigating += new WebBrowserNavigatingEventHandler(WebBrowser_Navigating);
void WebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) {
e.Cancel = true;
Process.Start(e.Url);
}
It will open default browser instead of opening this url inside webbrowser.

Response.Redirect() disables back-button

As far as I understand, Response.Redirect("http://stackoverflow.com"); tells the browser to initiate a request to another URL.
One of the results of this is that the browser "remembers" the redirection, and allows pressing "back."
However, I have a website where Response.Redirect disables the ability to press the browser's "Back" button, as if the browser had opened a new window. (Browsing history is not forgotten, unlike with Server.Transfer.)
The redirection used to work properly in the past, so I suspect the problem has something to do with the IIS server (IIS7).
I apologize in advance if this question should be moved to ServerFault.com.
UPDATES:
Here is some code:
protected void btnClickMe_Click(object sender, EventArgs e)
{
// ...
// some server-side logic
// ...
Response.Redirect("NewPage.aspx?ProductID=" + idNum);
}
Regarding "disables the ability to press the browser's 'Back' button", what I meant is that the button cannot be pressed. Same as when you open a new window. The button is gray, and clicking it has absolutely no effect.
UPDATE 2:
This has been tested with IE6 and IE8.
The problem was NOT with the Response.Redirect();.
When I was on OldPage.aspx, I entered a new URL in the address bar. Once the browser loaded the new site, it disabled the back-button.
Conclusion: There is something wrong with OldPage.aspx, not the redirection to NewPage.aspx.
I still don't know why THIS happens, but this is an entirely different question.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) //check if the webpage is loaded for the first time.
{
ViewState["PreviousPage"] =
Request.UrlReferrer;//Saves the Previous page url in ViewState
}
}
protected void btnBack_Click(object sender, EventArgs e)
{
if (ViewState["PreviousPage"] != null) //Check if the ViewState
//contains Previous page URL
{
Response.Redirect(ViewState["PreviousPage"].ToString());//Redirect to
//Previous page by retrieving the PreviousPage Url from ViewState.
}
}

ASP.Net ReportViewer control not working

I am using Reportviewer control in my .aspx page. I set
ReportViewer1.ShowPrintButton = false;
but it didn't work. Not only this button, i tried to show refresh button but it didn't work. thanks.
protected void Page_Load(object sender, EventArgs e) {
if (!this.IsPostBack)
PrintReport();
}
private void PrintReport() {
ReportViewer1.ShowPrintButton = false;
ReportViewer1.ShowRefreshButton = false;
}
You need to be running reports in remote mode in order for the buttons to work. In addition, if you want them to be shown, you have to set the values to True, not False as is shown in your code.
If you are running in local mode, there is an ActiveX control that can be downloaded, but this will only work for IE.
Here is a link to the MSDN documentation about printing from ReportViewer that should help you out.

Categories

Resources