我是从asp . net后面的代码调用Jquery函数,但它只显示一次不为其他

I am calling the Jquery function from code behind in asp net but it showing for one time only not for other

本文关键字:显示 其他 一次 net asp 函数 Jquery 调用 代码      更新时间:2023-09-26
        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();

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

从@banana的解释中了解到它偶尔有效,@user3840910请检查

的使用情况

ScriptManager。RegisterStartupScript

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

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

也是@user3840910,这将是一个很好的做法,格式化您的脚本,而不是错过在javascript的行末分号。