这真的让我疯狂已经上了好几个小时。按钮点击两次后回发
我有一个url,其查询字符串基于表单上选定的项目连接,我需要做一个帖子到这个url,但必须点击一个imagebutton控件来发布帖子。我将ImageButton的PostBackUrl属性放在图像按钮的事件中,因此在最终发布url之前使它被点击两次......但我确实需要点击一次,但这不起作用。我知道为什么它点击两次,试图调用JavaScript的网址,但它没有工作。
以下是代码。请帮助我的代码示例因为我还是一个新手,还挺。谢谢
protected void searchImageButton_Click(object sender, ImageClickEventArgs e)
{
returntype = tidRadioButtonList.SelectedItem.Value;
dateDlabel = selddate1TextBox.Text.Trim();
dateAlabel = seladate1TextBox.Text.Trim();
depart = seldcity1DropDownList.SelectedItem.Value;
arrive = selacity1DropDownList.SelectedItem.Value;
flightclass = selcabinclassDropDownList.SelectedItem.Value;
adult = seladultsDropDownList.SelectedItem.Text;
child = selchildrenDropDownList.SelectedItem.Text;
infant = selinfantsDropDownList.SelectedItem.Text;
result = resultbyRadioButtonList.SelectedItem.Value;
promos = promocodeTextBox.Text.Trim();
string theURL = "http://yyy.xxx.com/CAB/SessionHandler.aspx?target=%2fCAB%2fIBE.aspx&pub=%2fng%2fEnglish&Tab=1&s=&h=?tid=" + returntype +
"&seldcity1=" + depart.Trim() + "&selddate1=" + dateDlabel + "&selacity1=" + arrive.Trim() + "&seladate1=" + dateAlabel + "&selcabinclass=" + flightclass
+ "&seladults=" + adult + "&selchildren=" + child + "&selinfants=" + infant + "&resultby=" + result + "&promocode=" + promos;
searchImageButton.PostBackUrl = theURL;
}
我要张贴在URL中的数据(查询字符串)到另一个站点使用,以显示一些信息,结果查询字符串值。另一个网站无法访问我,我只能以这种方式发送数据。 – Tobby 2010-10-15 08:54:22
将数据发送到不同的网站?在这种情况下,您可能需要HTML表单并发布到该网站的某个页面。 – 2010-10-15 10:22:16
ImageButton将只发布到您的网站。或者,如果另一方接受HTTP GET请求,则可以使用HyperLink。 – 2010-10-15 10:24:54