Thursday, March 3, 2011

Is there a quick way to generate a <%@Register...%> line for a user control?

  • I make a user control and then want to include it on a page
  • I have to always manually type the @Register line at the top of my .aspx file, e.g.

    <%@ Register TagPrefix="edward" TagName="GetQuote" src="~/Controls/GetQuote.ascx" %>

  • Is there any way to automatically create these @Register lines?

(I tried dragging in the .ascx file from the Solution Explorer, doesn't work.)

Problem solved: I was dragging into my source view instead of design view. Thanks DilbertDave.

From stackoverflow
  • try adding your control to the toolbox (via Tools > Choose Toolbox Items) and then dragging it onto your page from the toolbox? (your controls would need to be in a separate dll)

  • I don't get this issue - are you dragging to the aspx in source or design mode?

    Dragging in Design mode creates the Register line for me.

0 comments:

Post a Comment