作业帮 > 综合 > 作业

无效的表达式else,貌似还有其他错误.

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/21 19:22:02
无效的表达式else,貌似还有其他错误.
#region 投票按钮Click事件
protected void btnVote_Click(object sender,EventArgs e)
{
if (this.RadioButtonList1.SelectedIndex =-1);//如果有选定项目
{
//投票防作弊
HttpCookie makecookie = new HttpCookie("Vote");//制造cookie
HttpCookie readcookie = Request.Cookies["Vote"];//读出cookie
if(readcookie == null )//从未投过票
{
makecookie.Values.Add("VoteItem","");
}
else
{
string strAllItem = readcookie.Values["VoteItem"].ToString();//读出以投票的项
if (strAllItem.IndexOf("") == -1)//未投过票
{
makecookie.Values.Add("VoteItem",readcookie.Values["VoteItem"]+"");
}
else//如果已经投过票
{
Response.Write("alert('该主题你已经成功投过票,不能重新投票!');");
return;
}
}
Response.AppendCookie(makecookie);//写入cookie
string strSelect = strContent.Split('|')[Convert.ToInt32(this.RadioButtonList1.SelectedValue.ToString())];//当前选中的项目
int intVote = Convert.ToInt32(strSelect.Split('.')[0];//当前投票数+1
int intVoteOK = intVote + 1;
string strSelectOK = strSelect.Replace(intVote.ToString(),intVoteOK.ToString());//更新原投票数
string strUPDATE = strContent.Replace(strSelect,strSelectOK);//得到最终结果
SqlData da = new SqlData();
bool update = da.ExceSQL("update 投票信息 set Content = " + strUPDATE +" where ID = " + strID + "");
if(update)
{
Response.Write("alert('投票成功!');");
}
else
{
Response.Redirect("Index.aspx");
}
}
else//如果没有选中项目
{
Response.Write("alert('请选择投票项!');location='javascript:history.go(-1)'");
}
}
#endregion
新手求教...以上是代码,请帮忙看下..
.
Response.AppendCookie(makecookie);//写入cookie
这句代码前面多了一个“}”了吧