Deploying a User ControlBecause a user control is dynamically generated and compiled, the page framework requires that the path to a user control be specified in one of three ways: relative to the page that uses (consumes) the user control (RequiredTextField.ascx), relative to the Web application root (~/Chapter4/UserControls /RequiredTextField.ascx), or as an absolute virtual path that lies within the current Web application (/BookWeb/Chapter4/UserControls/RequiredTextField.ascx). This requirement means that the files for a user control must reside in the directory (or subdirectory) of the consuming Web application. A user control can be developed as a part of any Web application, but to be used in another Web application, the .ascx file and other associated files ”such as the code-behind file and images, if any exist ”must be physically copied to the directory of the consuming Web application. In Visual Studio .NET, all the code-behind pages for user controls and for pages in a Web application are compiled into a single assembly. This imposes the additional requirement that all the code-behind pages be written in the same programming language. |