Adding User Controls from Sting can the User Control contain a CompileWith Control directive?

I want to store my User Controls in a DB. So I working with ParseControl and passing it a string. However when I pass as string of a control with codebehind I get this error.

My Code:

Dim strControl1 As String = "<%@ Control Language=""VB"" AutoEventWireup=""false"" CompileWith=""Control1.ascx.vb"" ClassName=""Control1_ascx"" %>" & vbCrLf & "<div>Control 1<br /><asp:PlaceHolder ID=""Control1PlaceHolder"" Runat=""server""></asp:PlaceHolder></div>"
Dim ctlControl1 As UserControl
ctlControl1 = Page.ParseControl(strControl1)


Parser Error Message: The virtual path '~/Control1.ascx.vb' maps to another application, which is not allowed.
Source Error:

Line 1: <%@ Control Language="VB" AutoEventWireup="false" CompileWith="Control1.ascx.vb" ClassName="Control1_ascx" %>
Line 2: <div>Control 1<br /><asp:PlaceHolder ID="Control1PlaceHolder" Runat="server"></asp:PlaceHolder></div>
10/15/2004 4:06:55 PM 93655 articles. 5 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 31

Also tried adding my code directly to the User Control and it ran but the code did not run.

My Code:

Dim strControl1 As String = "<script runat=""server"">" & vbCrLf & "Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load" & vbCrLf & "Response.Write(""Hello"")" & vbCrLf & "End Sub" & vbCrLf & "</script>" & vbCrLf & "<div>" & vbCrLf & "Control 1X<br />" & vbCrLf & "<asp:PlaceHolder ID=""Control1PlaceHolder"" Runat=""server""></asp:PlaceHolder>" & vbCrLf & "</div>"
Dim ctlControl1 As Control
ctlControl1 = Page.ParseControl(strControl1)

"Hello" never get written.
Any ideas?
10/15/2004 4:42:11 PM

Similar Artilces:

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

Can a user control contain another user control?
...? Sincerely,remedyMCP + Senior .NET DeveloperVista: Worth every penny. Yes, of course.Bertrand----This posting is provided "AS IS" with no warranties, and confers no rights. yes! this's ok!no problem!...

Persisting data in a web user control, which contains a list of other web user controls.
 Hi All, I have a control I've created, which can have a number of child controls - also user controls - stored as an ArrayList, which can be added wither a design time or programmatically.My problem is when I add to the list programmatically, it doesn't persist them. So if I add 3 child controls in step 1 of a wizard, with the aim that those three will be visible inside the parent in step 3, what happens is that the parent has no child controls and the item count is 0.Can anyone help? Thanks in advance.Code:Parent Control Markup: <%@ Control Language="C#" Auto...

user controls containing other user controls
I have a ContactInfo custom class that exposes AddressInfo custom class as property. I created two User Controls, you guess, Contact.ascx and Address.ascx. Address.ascx exposes property Address as AddressInfo. I am running into following problem. In Contact.ascx in page_load sub I am trying to set the values of the Contact class like this : _contact.PrimaryAddress = ctlAddress.PrimaryAddress but since value of the PrimaryAddress property in Address.ascx is set also in Page_Load, above code will not work since there is no instance of this object yet. Is my only option to mak...

(How) Can i use the form elements of a user control from another user control???
Hi, i have a user control with 4 other user controls. Actually i have 4 panels and each user control is inside a panel. Its like a 4 page form which are all connected to each other. Is it possible to have access to web controls that i have in my user controls from the main user control. In my main user control i have a submit button and a tab list. User can browse through the tabs and each tab is bound to a panel. so clicking on tab1 makes panel1 visible which holds the first user control, second tab makes second panel visible and the rest invisible and the second panel holds the ...

UpdatePanel within a web user control resets data of controls outside the user control
Hello, I have a usercontrol on my page which displays a running marquee text. It makes use of an UpdatePanel (within the user control) to refresh the marquee text (within the updatepanel) at periodic intervals. For this I added a timer control and its tick event as an async postback trigger for the UpdatePanel. I have a lot of textboxes and dropdown list boxes (all with runat=server) on the page outside the above user control. These are also contained in different UpdatePanels. Problem is, when the user control does a postback to refresh the marquee text, it causes some of...

User Control in a User Control
I have a first user control that contain a second user control. If I cahe the first user control can I still dynamically control the second one or it is cached with the first one therefore can not control it anymore? Thanks When your first control is cached, its rendered out and its output is stored in the cache. On every request to the page containing your control that can satisfy it from cache, the output will just simply be inserted - your first control will never be instantiated or run in that case, so the second one wont be either. Hope this helps,Mike VolodarskyProgram Manager...

User Controls in User Controls?
I have the follow set up and it is throwing an error "Unhandled error loading module" ... is there some trick to this that I don't know?I have a project A that uses controls from project B (project B is just a project with all my user controls used through out other modules).  project A uses user control 1 from project B with out any issues at all - great.  But then I wanted to add user control 2 to user control 1 and that is when I get my error.  In fact I don't even have the user control 2 in user control 1, just when I put the register part into user control 1 is when it al...

user control to user control
I have an aspx page that have a "Register" directive to two usercontrol called rptMaster.ascx and rptDetail.ascx. I'm trying to set up a Master-Detail relationship and wish for the rptMaster.ascx to trigger and event from a dropdownlist and for the rptDetail to be listening for DropDownList event. I believe I have gotten the events part okay with help from this articel but my declaration for a private statement to my rptMaster class is producing an error. I'm using beta 2 of and I 'm having trouble getting a reference TO ...

User control in a user control
Hello all, I have created a user control with some checkboxes, and public properties to get the values of these checkboxes. I have also created a second user control using the first user control; this second control also access the public properties of the first one. My problem is when I implement the second control in an aspx page, if I click at runtime the checkboxes in the first control, I am able to access its public properties from the methods of the second control but the values of these properties are wrong. while at design time, I do not have this problem. Than...

User Control Within UserControl
If I have a user control A and then inside it a user control B embedded/referenced within it.  User Control A has a panel defined (cpeNewUser) that I want to manipulate from the code behind of User Control B based on some event that happens.So putting this in my code behind of User Control B won't work as it has no idea of cpeNewUser:cpeNewUser.Collapsed = true;So is it because only at runtime they are married up and because of this you cannot access each other's objects at compile time?  How would I get this to work becuase I'm using all user controls inside a AJAX Too...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

Web resources about - Adding User Controls from Sting can the User Control contain a CompileWith Control directive? -

Kernel development
... kernel is 2.5.48 , which was released by Linus on November 17. Thisone includes the new module loader - so expect surprises if you compilewith ...

Mini vMac - early Macintosh emulator
News : ( Twitter ) May 29, 2012 Today's Mini vMac 3.3.1 alpha supports more host targets, has a few miscellaneous fixes,and adds a Polish translation. ...

The Boost Graph Library - 1.55.0
Graphs are mathematical abstractions that are useful for solving manytypes of problems in computer science. Consequently, theseabstractions must ...

The Boost Graph Library - 1.43.0
Graphs are mathematical abstractions that are useful for solving manytypes of problems in computer science. Consequently, theseabstractions must ...

The Boost Graph Library - 1.42.0
Graphs are mathematical abstractions that are useful for solving manytypes of problems in computer science. Consequently, theseabstractions must ...

The Boost Graph Library - 1.51.0
Graphs are mathematical abstractions that are useful for solving manytypes of problems in computer science. Consequently, theseabstractions must ...

Resources last updated: 12/2/2015 12:23:19 PM