Literal content (”) is not allowed within a ‘System.Web.UI.HtmlControls.HtmlTableCellCollection


I got this error in asp.net “Literal content (‘</AjaxToolkit:CalendarExtender>’) is not allowed within a ‘System.Web.UI.HtmlControls.HtmlTableCellCollection”.
I have the below code
<tr>
                <td>
                    <asp:Label ID=”lblTDate” runat=”server” Text=”Date”></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID=”txtDate” runat=”server” Width=”170px”></asp:TextBox>
                    <asp:Image ID=”imgDate” runat=”server” ImageUrl=”~/Images/CalendarImage.gif” />
                </td>
                    <AjaxToolkit:CalendarExtender ID=”CEDate” runat=”server” PopupPosition=”Right” PopupButtonID=”imgDate”
                        TargetControlID=”txtDate” Format=”dd/MM/yyyy”>
                    </AjaxToolkit:CalendarExtender>
</tr>
Here after this I added the runat=”server” id=”trDate” to the tr. like below:
<tr runat=”server” id=”trDate”>
When I rebuild the project, I got the above error.
Reason:
The reason behind that was AjaxToolKit CalendarExtender was out side <td> tag. It should be inside the <td></td> tag.
Solution:
So when I modify like below it worked.
<tr runat=”server” id=”trDate”>
                <td>
                    <asp:Label ID=”lblTDate” runat=”server” Text=”Date”></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID=”txtDate” runat=”server” Width=”170px”></asp:TextBox>
                    <asp:Image ID=”imgDate” runat=”server” ImageUrl=”~/Images/CalendarImage.gif” />
                    <AjaxToolkit:CalendarExtender ID=”CEDate” runat=”server” PopupPosition=”Right” PopupButtonID=”imgDate”
                        TargetControlID=”txtDate” Format=”dd/MM/yyyy”>
                    </AjaxToolkit:CalendarExtender>
                </td>
</tr>
You can also check out my previous posts on:
Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →