首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

RegisterStartupScript中的alert 弹出框无效解决方案

2013-01-04 
RegisterStartupScript中的alert 弹出框无效前台代码: script typetext/javascript$(function () {$(

RegisterStartupScript中的alert 弹出框无效
前台代码:

 <script type="text/javascript">
        $(function () {
            $("#delete").live("click",function () { //单击时执行删除操作,通过更改action属 性并提交表单来和后台交互
                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 partial class Reader_ReaderBorrowHistory : System.Web.UI.Page
{
    public string outputTable;
    protected void Page_Load(object sender, EventArgs e)
    {
               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(); //拼接字符串,赋值给outtable

        }

        else
        {
            outputTable = "<h1>该用户目前没有借书</h1>"; //拼接字符串,赋值给outtable
        }

        if (Request["cid"] != null)  //执行删除操作
        {
            int cid = int.Parse(Request["cid"]);
            
            bool result = borrow.DeleteByProc(cid);//如果成功删除,result为true
            if (result)
            {
                Page.ClientScript.RegisterStartupScript (this.GetType(),"","<script> alert('删除记录成功');script>"); 
            }
            else


            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> alert('删除记录失败');</script>");
            }
        }
    }

   }



现在的问题是虽然能够正常的删除记录但是RegisterStartupScript中的alert不起作用,删除成功的话,不会弹出对话框来提示删除成功,我调试了一下,也没报什么错误,这是怎么回事呢?大家帮帮忙,谢谢!
[解决办法]
没写完整
Page.ClientScript.RegisterStartupScript (this.GetType(),"key","<script>alert('删除记录成功');</script>"); 
[解决办法]
写错了你
Page.ClientScript.RegisterStartupScript (this.GetType(),"","<script> alert('删除记录成功');</script>"); 
这样
[解决办法]
写错了吧~~~
[解决办法]
你引用的JQ吧。有可能它引起的。

http://www.sunnybtoc.com/page/M0/S727/727872.html
[解决办法]
Page.ClientScript.RegisterStartupScript (this.GetType(),"","<script> alert('删除记录成功');window.location=‘index.aspx’</script>"); 
[解决办法]
Response.Write("<script>alert('删除记录成功');</script>");

热点排行