重新开贴 RegisterStartupScript中的alert 弹出框无效

wyumening 2012-12-10 10:19:18
前台代码
 <script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>

<script type="text/javascript">
$(function () {
$("#delete").live("click",function () {
var $id = $(this).attr("deleteid");
$("#form1").attr("action", "ReaderBorrowHistory.aspx?cid=" + $id);
$("#form1").submit();
});
});

</script>

<body>
<form id="form1" method="post" action="ReaderBorrowHistory.aspx">
<div>
<table id="Table1" style="font-family:Tahoma; font-size:12px; border-collapse:collapse ;" align="center" bgcolor="#f1f0f4" border="0" width="398">
<tr>
<td align ="center" >
<h1><font face ="GB_2312">借阅记录</font></h1>
<hr width ="90%" />
</td>
</tr>
<tr>
<td align ="center">
<%=outputTable %> <!-- outputtable是在后台定义的公共变量 用于放置动态拼接出的一个table -->
</td>
</tr>


</table>
</div>
</form>
</body>

后台代码
 public string outputTable;
protected void Page_Load(object sender, EventArgs e)
{
//if (!this.IsPostBack)
//{
// GridViewDataBind();
//}
StringBuilder sText = new StringBuilder();
sText.Append("<table id='table2'><tr><td>");
sText.Append("选择</td><td>");
sText.Append("题名/作者</td><td>出版信息</td>");
sText.Append("<td>借阅时间</td><td>应还时间</td></tr>");
Borrow borrow = new Borrow();
DataSet ds = borrow.QueryCurrentBorrow(Session["userID"].ToString());
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
sText.Append("<tr><td> <INPUT name=‘chkSon’ id='hkSon1' type='checkbox' value=" + row["BookID"].ToString() + "/></td>");
sText.Append("<td>" + row["BookName"].ToString() + "/ "
+ row["BookAuthor"].ToString() + "</td>");
sText.Append("<td>" + row["BookPublish"].ToString() + ""
+ row["BookPublishDate"].ToString() + "</td>");
sText.Append("<td>" + DateTime.Parse(row["BorrowBeginDate"].ToString()).ToString("yyyy-MM-dd") + "</td><td>"
+ DateTime.Parse(row["BorrowEndDate"].ToString()).ToString("yyyy-MM-dd") + "</td>");
sText.Append("<td><span>编辑</span></td>");
sText.Append("<td><span id='delete' deleteid='" + row["BorrowID"].ToString() + "'>删除</span></td></tr>");
}
sText.Append("</table>");
outputTable = sText.ToString();
}

else
{
outputTable = "<h1>该用户目前没有借书</h1>";
}

if (Request["cid"] != null)
{
int cid = int.Parse(Request["cid"]);

bool result = borrow.DeleteByProc(cid);
if (result)
{
Page.ClientScript.RegisterStartupScript (this.GetType(),"","<script> alert('删除记录成功');</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> alert('删除记录失败');</script>");
}
}
}

现在的问题是虽然能够正常的删除记录但是RegisterStartupScript中的alert不起作用,删除成功的话,不会弹出对话框来提示删除成功,我调试了一下,也没报什么错误,这是怎么回事呢?大家帮帮忙,谢谢!
...全文
173 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wyumening 2012-12-11
  • 打赏
  • 举报
回复
引用 2 楼 kongwei521 的回复:
<form id="form1" method="post" action="ReaderBorrowHistory.aspx"> 跟这个有没有关系。JQ里面写这里就。。
之前的action属性没有设置,也一样不会有弹出框提示删除成功
蝶恋花雨 2012-12-10
  • 打赏
  • 举报
回复
<form id="form1" method="post" action="ReaderBorrowHistory.aspx"> 跟这个有没有关系。JQ里面写这里就。。
threenewbee 2012-12-10
  • 打赏
  • 举报
回复
换成 RegisterClientScriptBlock 看看 或者 Page.ClientScript.RegisterStartupScript (this.GetType(),"这里加一个key看看","<script> alert('删除记录成功');</script>");

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧