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));
Related
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.
I want to show my google calendar in my application's tabs. How can I do it?
private void tabPage6_Click(object sender, EventArgs e)
{
//I want to add the code in this tab
}
You need to use a WeBrowser control for this. Drag and drop a WebBrowser control from Tools, suppose name of the WebBrowser control is webBrowser1 the use below code to open calendar
private void tabPage6_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.google.com/calendar/");
webBrowser1.Show();`
}
I am new to windows phone 8 development, I have MainPage.xaml which is start up page by Default, I have used this page as a login page, But every time I run my application it opens login page and need to put username and password, Instead of MainPage I want to set UserList.xanl as my start up page.
the next event is MainPage.xaml page_loaded event,
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/UserList.xaml", UriKind.Relative));
}
I dont want to use above code,
I have googled around but there was not any clue? Can anyone help me? Thanks
Did you try changing it in your WMAppManifest?
Reference: Setting The Start Page in Windows Phone 7 Application
You can change startup page in the app.xaml.cs file.
Find this method:
protected async override void OnLaunched(LaunchActivatedEventArgs e)
and change MainPage to UserList here:
if ( !rootFrame.Navigate( typeof(MainPage), e.Arguments ) )
I'm using a WebBrowser Control on a WPF application that opens a website with a form for the user to fill and submit. After submitting, it redirects to another page after 10 secs, www.google.com for example.
Is there a way to detect when the WebBrowser has opened www.google.com?
You can detect when the WebBrowser has opened your site name in webbrowser_LoadCompleted event,try this:
void webbrowser_LoadCompleted(object sender, NavigationEventArgs e)
{
mshtml.HTMLDocument doc =( mshtml.HTMLDocument) s.Document;
if (doc.parentWindow.window.location.host == "www.google.com")
{
MessageBox.Show("you navigated to google");
}
}
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.