Control Problem

RudeYute

Member
Joined
Dec 15, 2004
Messages
6
Programming Experience
Beginner
Hi,

I've created a menu which has categories created from an MS Access database, and have used the same code before with no problems, but this time, I get an error....

VB.NET:
[FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif]System.Web.HttpException: Control '_ctl0_ItemTypes__ctl0_ItemType' of type 'LinkButton' must be placed inside a form tag with runat=server.[/FONT]

This is my actual code, but I can't work out why it isn't working....

VB.NET:
<SCRIPT runat="server" language="vb">
        <asp:DataList id="ItemTypes" runat="server" OnItemCommand="GetCategory">
        <ItemTemplate>
            <asp:LinkButton id="ItemType" runat="server" font="Arial" Font-Size="10"  
                          Text=       '<%# Container.DataItem("Category") %>'
                          CommandName='<%# Container.DataItem("Category") %>'/>
          </ItemTemplate>
        </asp:DataList>
        </script>

Can anyone help? I have tried starting again a few times but still get the errror.

Thanks
 
Just as the error says, the controls must be placed inside a form tag with runat=server. Why are you wrapping the markup with script tags?
HTML:
<html>
  <body>
    <form id="form1" runat="server">
      <asp:DataList id="ItemTypes" runat="server" OnItemCommand="GetCategory">
        <ItemTemplate>
          <asp:LinkButton id="ItemType" runat="server" font="Arial" Font-Size="10"  
                   Text='<%# Container.DataItem("Category") %>'
                   CommandName='<%# Container.DataItem("Category") %>'/>
        </ItemTemplate>
      </asp:DataList>
    </form>
  </body>
</html>
 
Hi,

Managed to sort this soon after posting... turns out I had missed something else as well, although now I dont remember what or where.

Regards
 
Back
Top