asp.net - How to add a UserControl to another within a C# library?? (Exception: Could not resolve type...) -


I have a C # library that is built and placed in the bin folder of my website. In my C # library, I have a .ascx file and I'm trying to insert another. But I get this error:

The type for the "fb: FormBuilder" tag could not be resolved, make sure the proper namespace is registered.

This is at the top of my user control which I want to add to others:

  & lt;% @ control language = "c #" inheritance = "System.web.UI User Control, Etext Control"%> In my parents' control, I have this:  
  <% control = "C #"%> & Lt;% @ TagPrefix = "fb" tagname = "formbilder" Src = "~ / Resources / ControlTemplates / Backend / FormBuilder.ascx"%> .... & lt; Fb: formbilder runat = "server" id = "formcode" & gt; & Lt; / Fb: Form Builder & gt;  

All my files are set as build options in the form of "Embedded Resources" (.NET 3.5). Any ideas about how to solve it?

The declarative syntax of doing this in the actual ASX file itself is to be a file in that place where you Specify in the registration declaration. If that file is not present, then the compiler does not know how to solve the reference.

Generally, if you have author controls that are designed to reuse other web applications, then they should be created as a custom server control; Not designed as user control is designed for server control structures and base class reuse and packaging. Writing the server controls initially takes a little more time and effort, but not too much and once you do this, it is quite easy once or twice.

I can think that there is only one other solution that your creation / compilation is leaving the actual ASX files in a certain place within the consumer web project. In this way your consumer pages will have a valid path to use in the Register Instructions and may be located by the file compiler. You can use code-behind to load the control dynamically using Page.LoadControl (). The ASX file should be physically present, but using the code-behind to add controls to the page will allow you to add some intelligence to the process by configuring the path in the configuration and the like.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -