我必须检查从DDL中的数据库检索数据,如果此数据等于特定值,则用户将重定向到特定站点(URL)。我尝试使用if语句进行此操作但是它没有用,请任何人帮助我。
protected void IMGSite_Click(object sender, ImageClickEventArgs e)
{
if (DDLBrand.SelectedItem.Text="Sharp")
{
Response.Redirect("http://toshiba.elarabygroup.com/");
}
if (DDLBrand.SelectedItem.Text = "Seiko")
{
Response.Redirect("http://Seiko.elarabygroup.com/");
}
}
答案 0 :(得分:1)
DDLBrand.SelectedItem.Text = "Seiko"
应该是
DDLBrand.SelectedItem.Text == "Seiko"
使用两个等号!其他比较相同(==“夏普”)
编辑: 要在新窗口中打开,请尝试:
Response.Write("<script type='text/javascript'>window.open('http://toshiba.elarabygroup.com/');</script>")