我正在尝试在仪表板上放置多个用户控件。但只有一个用户控件可见。
仪表板.aspx:
<table cellpadding="0" cellspacing="0" border="0" width="220px">
<tr>
<td>
<dc:MyControl ID="c1" runat="server"/>
</td>
<td>
<dc:MyControl ID="c2" runat="server"/>
</td>
</tr>
</table>
看起来在用户控件中创建的全局对象覆盖了另一个。
然后我将我的javascript代码更改为:
MyControl.ascx:
//Display gauge on the page (has some html5 elements like canvas)
<div id="gauge1" class="gauge"></div>
<script type="text/javascript">
var <%=this.ClientID%>global = new jGauge(); // Create a new gauge.
<%=this.ClientID%>global.id = 'gauge1'; // Link the new gauge to the placeholder DIV.
// This function is called by jQuery once the page has finished loading.
$(document).ready(function () {
<%=this.ClientID%>global.init(); // Put the gauge on the page by initializing it.
});
</script>
但仍然只有一个用户控件可见。有什么建议么?