我从asp网络中的代码调用Jquery函数,但它只显示一次而不是其他

时间:2014-07-15 12:54:12

标签: javascript jquery asp.net

        ServerMonitoringDetails objServerMonitorings = new ServerMonitoringDetails();
        objServerMonitorings = ServerMonitoringBusinessManager.GetAllIpDetailsByIpAddress();
        StringBuilder sbPhysicalMemory = new StringBuilder();
        sbPhysicalMemory.Append("Physical Memory");
        sbPhysicalMemory.Append("<div class=\"MemoryFixed\">");
        sbPhysicalMemory.Append("<a href=\"ServerMonitoringGraphDetails.aspx?Ip=KHUSHVINDER-PC\">KHUSHVINDER-PC</a>");
        ScriptManager.RegisterStartupScript(this.divPhysicalMemory, this.Page.GetType(), "script", "<script type='text/javascript'>bind(div1,50,200);</script>", false);
        sbPhysicalMemory.Append("<div id=\"div1\">");
        sbPhysicalMemory.Append("</div>");
        sbPhysicalMemory.Append("</div>");
        divPhysicalMemory.InnerHtml = sbPhysicalMemory.ToString();
        StringBuilder sbVirtualMemory = new StringBuilder();
        sbVirtualMemory.Append("Virtual Memory");
        sbVirtualMemory.Append("<div class=\"MemoryFixed\">");
        sbVirtualMemory.Append("<a href=\"ServerMonitoringGraphDetails.aspx?Ip=KHUSHVINDER-PC\">KHUSHVINDER-PC</a>");
        ScriptManager.RegisterStartupScript(this.divVirtualMemory, this.Page.GetType(), "script", "<script type='text/javascript'>bind(divVM,100,200);</script>", false);
        sbVirtualMemory.Append("<div id =\"divVM\">");
        sbVirtualMemory.Append("</div></div>");
        divVirtualMemory.InnerHtml = sbVirtualMemory.ToString();

嗨,这是我上面的代码,我在代码后面两次调用相同的函数但没有工作

1 个答案:

答案 0 :(得分:0)

从@ banana的解释中了解到它偶尔会起作用, @ user3840910请检查您的使用情况

  

ScriptManager.RegisterStartupScript

该方法的第三个参数应该是要注册的脚本的唯一标识符。

请参阅:http://msdn.microsoft.com/en-us/library/bb359558(v=vs.110).aspx

另外@ user3840910,最好在发布时格式化脚本,不要错过javasript行末尾的分号。