我現在的問題是,我需要點擊2次以搜索正確的文本進行搜索。有沒有辦法檢視我發送的內容並更新它?還有其他解決方案嗎?兩個決定只是一個按鈕
你好!
我有2個單選按鈕,決定使用什麼搜索引擎(谷歌或我的),我有1個按鈕,將提交一個文本,將用於搜索在2搜索引擎之一。當我嘗試執行谷歌搜索時,第一次只是在第二次點擊時打開新窗口,它會打開帶有我想要搜索的詞的谷歌窗口,如果我嘗試執行搜索,則執行兩次搜索。我做錯了什麼?我如何以正確的方式工作?
<table><tr>
<td>
<asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="Button1_Click" UseSubmitBehavior="true"/>
</td>
</tr>
<tr align="center">
<td>
<input id="Search1" value="one" type="radio" runat="server" name="sitesearch" />Site Name
<input id="Search2" value="two" type="radio" runat="server" name="sitesearch" />
<img src="http://www.google.com/images/poweredby_transparent/poweredby_FFFFFF.gif" alt="Google" />
</td>
</tr>
</table>
,然後我有...
protected void Button1_Click(object sender, EventArgs e){
if (Search1.Checked)
{
//My Search
Response.Redirect(Request.UrlReferrer.AbsolutePath +...
}
else if (Search2.Checked)
{
//Google search
btnSearch.Attributes.Add("OnClick", "window.open('http://www.google.com/search?q=" + Regex.Replace(TextB.Text, " ", "+") + "','_blank');");
}
}
...我有這個...
TextBox TextB;
HtmlInputRadioButton radioBSite;
Button btnSearch;
HtmlInputRadioButton radioBGoogle;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
TextB = (TextBox)FindControl("TextBox1");
TextB.Text = Request["find"];
radioBSite = (HtmlInputRadioButton)FindControl("Search1");
radioBSite.Checked = true;
radioBGoogle = (HtmlInputRadioButton)FindControl("Search2");
btnSearch = (Button)FindControl("btnSearch");
btnSearch.Click += new EventHandler(Button1_Click);
.
.
}
但後來我不需要按鈕嗎?我只想搜索當我點擊按鈕不當我選擇單選按鈕。如果我這樣做會怎麼樣? – SlimBoy 2009-11-27 16:04:32