Lee dialog 对话框关闭后刷新父页

Lee dialog对话框很好用,简结明了。有时候我们在Lee dialog对话框中更新文章后,需要在关闭Lee dialog的时候更新父页,当然在按钮动作中添加<script>parent.location.reload()</script> 就可解决,可以当你在父页里点过按钮后再用Lee dialog修改文章时就会发现,每次提交后,IE总会弹出对话框,让你确认是否重新提交,让人感觉很不爽,经过研究后发现,可以用另一条路解决这个问题,当然这个路走得有些远,那也是没办法的事,如果你有什么好方法就请告诉我。

我采用的方法是关闭Lee dialog的JS代码里调用ASPX里的按钮事件,实现信息更新。就是下面红色的代码。

还有一个文件是jquery-latest.pack.js,自己到网上下载,两个文件一起才能启用Lee dialog

dialog.js文件信息如下:

// Lee dialog 1.0 http://yushuir.blog.163.com

var dialogFirst=true;
function dialog(title,content,width,height,cssName){
//open DIV
if(dialogFirst==true){
  var temp_float=new String;
  temp_float="<div id=\"floatBoxBg\"></div>";
  temp_float+="<div id=\"floatBox\" class=\"floatBox\">";
  temp_float+="<div class=\"title\"><h4></h4><span>鍏抽棴</span></div>";
  temp_float+="<div class=\"content\"></div>";
  temp_float+="</div>";
  $("body").append(temp_float);
  dialogFirst=false;
 
  $("#floatBox .title span").click(function(){
    $("#floatBoxBg").hide();
    $("#floatBox").hide();
  });
}
$("#floatBox .title h4").html(title);
contentType=content.substring(0,content.indexOf(":"));
content=content.substring(content.indexOf(":")+1,content.length);
switch(contentType){
  case "url":
  var content_array=content.split("?");
  $("#floatBox .content").ajaxStart(function(){
    $(this).html("loading...");
  });
  $.ajax({
    type:content_array[0],
    url:content_array[1],
    data:content_array[2],
 error:function(){
   $("#floatBox .content").html("error...");
 },
    success:function(html){
      $("#floatBox .content").html(html);
    }
  });
  break;
  case "text":
  $("#floatBox .content").html(content);
  break;
  case "id":
  $("#floatBox .content").html($("#"+content+"").html());
  break;
  case "iframe":
  $("#floatBox .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
}

$("#floatBoxBg").css({display:"block",height:$(document).height()});
$("#floatBox").removeClass();
$("#floatBox").attr("class","floatBox "+cssName);
$("#floatBox").css({display:"block",left:(($(document).width())/2-(parseInt(width)/2))+"px",top:($(document).scrollTop()+50)+"px",width:width,height:height});
}

//close DIV
function close_dialog() {
 $("#floatBox").hide();
    $("#floatBoxBg").hide();
 document.getElementById("ctl00_ContentPlaceHolder1_Button_Refresh").click();
}

 

Lee dialog调用文件的cs里文件调用

 //数据写入
                if (SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, Sql, param) == 1)
                {
                    Response.Write("<script>alert('成功!');parent.close_dialog();</script>");
                }
                else
                {
                    Response.Write("<script>alert('系统出错,请联系网站管理员!错误代码063');history.back();</script>");

                }

 

父文件aspx里

<asp:Button ID="Button_Refresh" runat="server" OnClick="Button_Refresh_Click" Height="0px" Width="0px" />

cs文件写上相应刷新的动作。

 protected void Button_Refresh_Click(object sender, EventArgs e)
    {
        Article_List_Data();
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值