61,653
社区成员




<!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>
<script src="jquery-1.8.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
var uid = [],usercount;
function GetUser() {
uid = [];
var userIds = document.getElementsByName("UserId");
for (i = 0; i < userIds.length; i++) {
if (userIds[i].checked) {
uid.push(userIds[i].value);
}
}
if (uid.length == 0) {
alert("请选择用户");
return;
}
usercount = 0;
ProcessUserData();
}
function ProcessUserData() {
if (usercount >= uid.length) {
alert("所选用户处理完毕!");
$("#Debug").html("所选用户处理完毕!");
return;
}
$("#Debug").html("正在处理 id = " + uid[usercount]);
$.ajax({
url: '<%=Request.FilePath %>?UserId=' + uid[usercount] + "&step=1&t=" + (new Date()).valueOf(),
dataType: "text",
success: function (data) {
if (data.indexOf("用户成绩已经存在") > -1) {
var ret = window.confirm("id=" + uid[usercount] + " 的用户成绩已经存在,你要否要覆盖??");
if (ret) {
//用户选择了“是”,就进行覆盖操作
$.ajax({
url: '<%=Request.FilePath %>?UserId=' + uid[usercount] + "&step=2&t=" + (new Date()).valueOf(),
dataType: "text",
success: function (msg) {
alert(msg);
usercount++;
ProcessUserData()
}
});
}
else {
usercount++;
ProcessUserData()
}
}
else {
usercount++;
ProcessUserData()
}
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
<table>
<thead>
<tr>
<th>选择</th>
<th>工号</th>
<th>姓名</th>
</tr>
</thead>
<tbody>
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</tbody>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<input name="UserId" type="checkbox" value='<%# Eval("UserId")%>' />
</td>
<td>
<%# Eval("UserId")%>
</td>
<td>
<%# Eval("UserName")%>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:Button ID="Button1" runat="server" Text="测试处理" OnClientClick="GetUser();return false;" />
<div id="Debug"></div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
String step = Request.QueryString["step"];
if (String.IsNullOrEmpty(step))
{
//首次进来,执行绑定
if (!Page.IsPostBack)
{
System.Data.DataSet ds = new System.Data.DataSet();
System.Data.DataTable dataTable1 = new System.Data.DataTable("BlogUser");
System.Data.DataRow dr;
dataTable1.Columns.Add(new System.Data.DataColumn("UserId", typeof(System.Int32)));
dataTable1.Columns.Add(new System.Data.DataColumn("UserName", typeof(System.String)));
for (int i = 0; i < 8; i++)
{
dr = dataTable1.Rows.Add(new Object[] { i, "【孟子E章】" + i.ToString() });
}
ListView1.DataSource = dataTable1;
ListView1.DataBind();
}
}
else
{
Response.ContentType = "text/plain";
Response.Expires = -100;
String UserId = Request.QueryString["UserId"];
if (step.Equals("1"))
{
//判断用户成绩是否存在,这里假定id=2,3,6的用户存在,实际应用是查数据库判断
if (UserId.Equals("2") || UserId.Equals("3") || UserId.Equals("6"))
{
Response.ClearContent();
Response.Write("用户成绩已经存在");
Response.End();
}
else
{
Response.ClearContent();
Response.Write("");
Response.End();
}
return;
}
else if (step.Equals("2"))
{
//进行覆盖操作
Response.ClearContent();
Response.Write("用户" + UserId + "已经被覆盖。");
Response.End();
return;
}
}
}
function confrim()
{
if (confirm("是否继续执行?")) {
document.getElementById("hidFalg").value = "1";
// 通过__doPostBack调用后台方法
__doPostBack('ctl00$main$btnFunction', '');
}
else
{
document.getElementById("hidFalg").value = "0";
}
|
// 需要在画面上加个隐藏域hidFalg
If "0".Equals(hdnTouroku.Value) = True Then
' 确认之前的处理写在这里
' 确认消息
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), DateTime.Now.ToString().Replace(":", " "), _
"confirm();", True)
'hdnTouroku.Value = "1"
ElseIf "1".Equals(hdnTouroku.Value) = True Then
' 确认之后要继续的处理写在这里
end if