Adding multiple user controls in table

Total Post:341

Points:2389
 952  View(s)
Ratings:
Rate this:

I'm trying to put multiple user controls on the dashboard. But only one user control is visible.

Dashboard.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>

It looked like the global object created in user control overwrites the other one.

I then changed my javascript code as:

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>

But still only one user control is visible. Any suggestions?

  1. Post:378

    Points:2694
    Re: Adding multiple user controls in table

    Hi Ankit, 

    try this:

    <table cellpadding="0" cellspacing="0" border="0" width="100%">

        <tr>

            <td style="width:50%;">

                <dc:MyControl ID="c1" runat="server"/>

            </td>

            <td style="width:50%;">

                <dc:MyControl ID="c2" runat="server"/>

            </td>

        </tr>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!