我正在用c#編寫一個程序。在最後的形式中,我得到了一個名爲「電話簿」的按鈕。當我按下它時,它應該打開一個帶有「tel.search.ch」網址的網頁瀏覽器(它是瑞士的德國網站)。我已經研究過網站的網址。它是這樣的:使用c在電話簿網頁上的webbrowser動態鏈接#
tel.search.ch/?what=forename+surname &其中= livingplace
但是當我按一下按鈕,它會打開網頁瀏覽器,但該網址是該網站的主站點。所以webbrowser導航到tel.search.ch而不是我定義的URL。在這裏你可以看到我的代碼:
Form5(最後形式按鈕):
private void btnTel_Click(object sender, EventArgs e)
{
Form6 form6 = new Form6();
this.Hide();
form6.Show();
}
Form6(網頁瀏覽器):
public partial class Form6 : Telerik.WinControls.UI.RadForm
{
public Form6()
{
InitializeComponent();
}
public string forename;
public string surname;
public string address;
public string postalcode;
public string livingplace;
private void Form6_Load(object sender, EventArgs e)
{
webBrowser1.Url = new Uri("http://tel.search.ch/?what=" + forename + "+" + surname + "&where=" + livingplace);
//this code is that my program got the value of the textbox from form1 and form2. it is defined in Program.cs
Program.forenametext = vorname;
Program.surnametext = nachname;
Program.livingplacetext = ort;
}
}
我不知道爲什麼在網頁瀏覽器導航到家庭本網站的網站。有人有個想法嗎?
歡呼
你確定你的URL格式是否正確?我嘗試了你給的那個,它似乎沒有工作。但是玩弄網站的按鈕,發現像「http://tel.search.ch/?was=john」這樣的東西確實有效。 –
hm是的我已經在ie,ff和chrome中測試了很多次,它似乎工作。只有當我運行它的程序,它不起作用 – Roman