Powered by Blogger.

Saturday, February 15, 2014

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:
- Adding meta tags to aspx pages in asp.net

- Asp.Net MVC4 Controller class example

- Enum in C#.Net





0 comments

Post a Comment