前台页面如下:
- C# code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Province.aspx.cs" Inherits="Admin_Channel_Province" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>编辑开通省份</title> <link href="../../css/Public.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript"> function addch() { if (confirm("您确认要提交所选省份吗?")) { var List = ""; var strID = document.getElementsByName("checkbox1"); for (var i = 0; i < strID.length; i++) { if (strID[i].checked) { List += strID[i].value + ","; } } if (List == "") { alert("请选择省份"); return; } var ch = document.getElementById("ch").value; var ct = document.getElementById("ct").value; Admin_Channel_Province.addprovince(List, ch, ct, GetCallBack); //这里提示Admin_Channel_Province未定义 } function GetCallBack(response) { var result = response.value; if (result == "OK") { alert("编辑成功"); } } } </script></head><body><script src="../../js/Calendar.js" type="text/javascript"></script> <form id="form1" runat="server"> <div class="l_f_top"> <div class="l_f_top_left_div"><img alt="" src="../../images/tab/tb.gif" width="16" height="16" /></div> <div class="l_f_top_right_div">编辑省份</div> </div> <div id="divList" class="l_f_body"> <div align="left"> <input type="checkbox" value="-1" name="allID" id="allID" onclick="javascript:selectAll(this.form,this.checked)" />全选 </div> <input type="checkbox" name="checkbox1" value="1" />福建 <input type="checkbox" name="checkbox1" value="2" checked="checked" />广东 <input type="checkbox" name="checkbox1" value="10" checked="checked" />贵州 <input type="checkbox" name="checkbox1" value="11" />陕西 <input type="checkbox" name="checkbox1" value="12" />青海 <input type="checkbox" name="checkbox1" value="13" />海南 <div class="center l_f_body_foot"> <input type="button" onclick='addch();' value="提 交" class="button_60" /> <input type="button" onclick='javascript:window.history.go(-1);' value="返 回" class="button_60" /> </div> </div> <input type ="hidden" id="ch" name ="ch" value ="<%=CH%>"/> <input type ="hidden" id="ct" name ="ct" value ="<%=CT%>"/> </form></body></html>
后台页面如下:
- C# code
using System;using System.Collections.Generic;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Text;using t.BLL;using t.DataModel;using t.Common;public partial class Admin_Channel_Province : System.Web.UI.Page{ protected int CH = 0; protected int CT = 0; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CH = TypeParse.StrToInt32(Request.QueryString["ch"], 0); CT = TypeParse.StrToInt32(Request.QueryString["ct"], 0); } AjaxPro.Utility.RegisterTypeForAjax(typeof(Admin_Channel_Province)); } [AjaxPro.AjaxMethod] public string addprovince(string strID, int CH, int CT) { string str = ""; string err = "OK"; if (strID.IndexOf(",") > 0) { str = strID.Substring(0, strID.Length - 1); } else { str = strID; } try { ProvinceBLL ProvinceBLL = new ProvinceBLL(); if (ProvinceBLL.UpdateProvince(CH, CT, str) < 0) { err = "意外错误,编辑失败!"; } } catch (Exception e) { err = e.Message; } return err; }}