Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thor Østergaard 37 posts 58 karma points
    Sep 27, 2011 @ 07:40
    Thor Østergaard
    0

    Usercontrols - what am I doing wrong?

    I have the following simple usercontrol:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="HelloWorld.ascx.cs" Inherits="HelloWorld" %>
    <h1>HelloWorld</h1>
    <p><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></p>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

    Have created a macro using the usercontrol and have inserted that macro on a page (using the editor).
    Have have published the site in VS2010pro and copied the dll file to the bin folder on my umbraco site and the ascx file to det usercontrol folder.
    The text on from the usercontrol is shown on the page but not the controls :(
    What's wrong?

  • Rich Green 2246 posts 4008 karma points
    Sep 27, 2011 @ 08:01
    Rich Green
    0

    Hey Thor,

    Is the user control wrapped in a <form runat="server"> tag?

    Rich

  • Thor Østergaard 37 posts 58 karma points
    Sep 27, 2011 @ 08:04
    Thor Østergaard
    0

    no

  • Thor Østergaard 37 posts 58 karma points
    Sep 27, 2011 @ 08:28
    Thor Østergaard
    0

    do I need to have a form tag in my template?

  • Rich Green 2246 posts 4008 karma points
    Sep 27, 2011 @ 08:29
    Rich Green
    0

    Hi,

    You need to wrap the usercontol in a <form runat="server"> if you want to use runat="server" controls

    Rich

  • Rich Green 2246 posts 4008 karma points
    Sep 27, 2011 @ 08:30
    Rich Green
    0

    Sorry, crosspost.

    Yes, put it in your template, you can put it just after your body tag in your master template as there can only be one per page.

    Rich 

  • Thor Østergaard 37 posts 58 karma points
    Sep 27, 2011 @ 08:32
    Thor Østergaard
    0

    I can see I need that - thanks :)

Please Sign in or register to post replies

Write your reply to:

Draft