Was creating a browser and was testing how different websites load and noticed on some website the C# web browser will not fully load specific websites. Seems to default to mobile maybe?
For example, Apartmentbutler.com
Compared to full browser
Another example, cleancloudapp, gets stuck here.
For sake of details - very basic.
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load_1(object sender, EventArgs e)
{
webBrowser1.ScriptErrorsSuppressed = true;
}
private void button1_Click(object sender, EventArgs e)
{
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
string webPage = textBox1.Text.Trim();
webBrowser1.Navigate(webPage);
}
}
}
Is this something because of the webdeveloper? If it's because mobile, why not loading properly? Can I use useragent to force to desktop?
Would appreciate any help, thank you.
By default, the WebBrowser control runs in compatibility view mode. Compatibility view mode is basically document mode 7. That most likely caused the rendering issue.
You can change the IE version for webbrowser control by adding HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\yourapp.exe and set its DWord value to e.g. 11001 (IE 11)
For 32 bits machine add under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\
Details at https://msdn.microsoft.com/library/ee330730(v=vs.85).aspx#browser_emulation
Related
i am making web browser in windows form by using c# where i can set values of loaded html's input fields automatically by clicking on button. when i simply put code in click event of button its work fine`
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("username").SetAttribute("value","admin");
webBrowser1.Document.GetElementById("password").SetAttribute("value","12345");
}`
but when i try to this via threading it gives me error
Specified cast is not valid?
private void button1_Click(object sender, EventArgs e)
{
Thread thread1 = new Thread(new ThreadStart(setvalues));
thread1.Start();
}
void setvalues()
{
webBrowser1.Document.GetElementById("username").SetAttribute("value","admin");
webBrowser1.Document.GetElementById("password").SetAttribute("value","12345");
Thread.Sleep(8000);
}
}
where i am doing mistake in code ? any error? am beginner i need help
You can't access forms controls in a separate thread. Try this in setvalues():
Invoke((Action)(() => {
webBrowser1.Document.GetElementById("username").SetAttribute("value","admin");
webBrowser1.Document.GetElementById("password").SetAttribute("value","12345");
}));
I am making an android app using C# in Xamarin studio. I managed to make the checkboxes and among other things. I need to know what code I would need to use make a the checkbox go to redirect to another page if checked. I am new to programming so I am sure this is an easy question but I am having trouble.
This is what you need to do
private void MainPage_Load(object sender, EventArgs e)
{
checkBox1.CheckedChanged += checkBox1_CheckedChanged;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
// your code to go to the other page.
}
}
I am trying to make a web browser with multiple tabs. But now, I have a problem with the DocumentTitle for the name of the tabs.
The problem here is that the code to name the tab is performed before it loads the page. I tried to find a way to perform it after, but it doesn't work.
For example:
private void stackoverflowToolStripMenuItem_Click(object sender, EventArgs e)
{
((WebBrowser) tabControl1.SelectedTab.Controls[0]) .Navigate("Http://www.stackoverflow.com/");
Browser_Navigated(null, null);
}
void Browser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
tabControl1.SelectedTab.Text = ((WebBrowser)tabControl1.SelectedTab.Controls[0]).DocumentTitle;
}
The WebBrowser class exposes a DocumentTitleChanged event that you can use to update the tab title.
I have .net win form application , its a pretty big application , first i was using .Net original controls , than i switched to Telerik and deleted the old control and create new button , checkes etc with same name and than due to some problem reverted back to original
.Net controls ,
i have more than 200 controls , and all my code look like this , its so mess , is there any easy way that i can relate only working event to my control with removing _1 , _2 , _3
mean is there any automated way ?
using vs 2012 and .net 4
private void chkPk_CheckedChanged_1(object sender, EventArgs e)
{
// Code
}
private void chkPk_CheckedChanged_2(object sender, EventArgs e)
{
// Code
}
private void chkPk_CheckedChanged_3(object sender, EventArgs e)
{
// Code
}
Maybe it's about addhandler
this.chkPk_1.CheckedChanged += new System.EventHandler(this.myEventHandler);
this.chkPk_2.CheckedChanged += new System.EventHandler(this.myEventHandler);
private void myEventHandler(object sender, EventArgs e)
{
// Code
}
See the reference .. http://msdn.microsoft.com/en-us/library/aa984308(v=vs.71).aspx
Hi i want to do like this. i'm writing a webbrowser application in c# and i will set as default browser.but i have one problem if i set it won't open clicked link from other program or html file on desktop.
how can i do that ?
it should be like this photos.
i hope you understand my english.sorry for my english. :)
private void Form1_Load(object sender, EventArgs e)
{
panel3.BackColor = Doga_Rhodonit.Properties.Settings.Default.themebg;
((WebKitBrowser)tabControl1.SelectedTab.Controls[0]).Navigate(what should i write or what event should i write??);
If your browser is set to the default when a link is pressed the OS will send the URL as a argument
string URL = null;
public static void Main(string[] args)
{
Console.WriteLine(args[0]);
URL = args[0];
}
private void Form1_Load(object sender, EventArgs e)
{
panel3.BackColor = Doga_Rhodonit.Properties.Settings.Default.themebg;
((WebKitBrowser)tabControl1.SelectedTab.Controls[0]).Navigate(URL);