无效的表达式else,貌似还有其他错误.#region 投票按钮Click事件protected void btnVote_Click(object sender,EventArgs e){if (this.RadioButtonList1.SelectedIndex =-1);//如果有选定项目{//投票防作弊HttpCookie makecookie = new H
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/04 12:20:35
![无效的表达式else,貌似还有其他错误.#region 投票按钮Click事件protected void btnVote_Click(object sender,EventArgs e){if (this.RadioButtonList1.SelectedIndex =-1);//如果有选定项目{//投票防作弊HttpCookie makecookie = new H](/uploads/image/z/6970532-68-2.jpg?t=%E6%97%A0%E6%95%88%E7%9A%84%E8%A1%A8%E8%BE%BE%E5%BC%8Felse%2C%E8%B2%8C%E4%BC%BC%E8%BF%98%E6%9C%89%E5%85%B6%E4%BB%96%E9%94%99%E8%AF%AF.%23region+%E6%8A%95%E7%A5%A8%E6%8C%89%E9%92%AEClick%E4%BA%8B%E4%BB%B6protected+void+btnVote_Click%28object+sender%2CEventArgs+e%29%7Bif+%28this.RadioButtonList1.SelectedIndex+%3D-1%29%3B%2F%2F%E5%A6%82%E6%9E%9C%E6%9C%89%E9%80%89%E5%AE%9A%E9%A1%B9%E7%9B%AE%7B%2F%2F%E6%8A%95%E7%A5%A8%E9%98%B2%E4%BD%9C%E5%BC%8AHttpCookie+makecookie+%3D+new+H)
无效的表达式else,貌似还有其他错误.#region 投票按钮Click事件protected void btnVote_Click(object sender,EventArgs e){if (this.RadioButtonList1.SelectedIndex =-1);//如果有选定项目{//投票防作弊HttpCookie makecookie = new H
无效的表达式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
新手求教...以上是代码,请帮忙看下..
.
无效的表达式else,貌似还有其他错误.#region 投票按钮Click事件protected void btnVote_Click(object sender,EventArgs e){if (this.RadioButtonList1.SelectedIndex =-1);//如果有选定项目{//投票防作弊HttpCookie makecookie = new H
Response.AppendCookie(makecookie);//写入cookie
这句代码前面多了一个“}”了吧