Trying to load a control into a control from another control

Exactly as the subject states, I'm trying to load a control into another control from a control loaded into a page, I keep getting this error from the code I have below.  I've also tried the findcontrol but it keeps coming up null.

(67): 'System.Web.UI.UserControl' denotes a 'class' where a 'variable' was expected

UserControl ut = ((webcontrols.BrowseItems)UserControl).LoadControl("BrowseItems");
((webcontrols.BrowseItems)UserControl).pnl_browse_main.Controls.Add(ut);

0
thespace
1/19/2005 3:36:24 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

1 Replies
1260 Views

Similar Articles

[PageSpeed] 47

This is how we Load User controls into a content place holder.


try
{
UserControl ctl;
ctl = (UserControl)LoadControl(PagePath.ReturnPagePath(Request.QueryString["CurrentPage"]));
this.contentPlaceholder.Controls.Add(ctl);
}
catch (Exception ex)
{
Response.Write(ex.Message);
Response.Write("Unable to load " + (string)Session["CurrentPage"] + " control");
}

You need to replace the whole ctl call with the UserControl object the you created. When you Response.Write your execption on a load fail. change the output to whatever you would like to display.
By looking at your naming scheme it looks like you just want to fill a Panel. For this we usually make a Panel on the page and goto the solution explorer then drag and drop the usercontrol we wish to display into the panel. If you are not wanting to change this dynamically later in your solution the drag and drop is the easiest way to go.

It's not a bug, it's a feature.



Brian Parker
CEO, Cofounder
NeoTekSystems
Phone:(864)770-0473
Fax:(864)770-0476
www.neoteksystems.com
bparker@neoteksystems.com
0
brianparker
1/19/2005 4:12:32 PM
Reply:

Similar Artilces:

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this?  AllAboutFocus.com. Information Technology SolutionsHelping You Focus. Helping You Succeed. Here's a hint for you... ascx user controls are self-contained objects that hide their contents from other applications.  When you build them, you will need to place in properties and methods are are accessable from an outside. Here is a down-and-dirty example Create a usercontrol. name it HelloOutsideWorld.ascx with the following contents:<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HelloOutsideWorld.ascx.cs" Inherits="HelloOutsideWorld" %> <asp:Label ID="lblMessage" runat="server" Text="Awaiting Message From The Outside..."></asp:Label>  Here is the codebehind for HelloOutsideWorld.ascx.cs:using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using S...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

controlling an object in a web control from the page the web control is placed in
I have created a web control in vb.net that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

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...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal contols.... on the other page(aspx page)... means are you using the user control in aspx page...Chinna_sv... Hi, If your Label Control resides withing a UserControl or in a Data Representaion Controls like (GridView, FormView, DataList etc..) then you can use FindControl method to reference/access the controls in your codes..Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET...

Controls.Add in Composite Control that inherits another control
Hi! I created a composite control that inherits from the WebControls.Button. I added the following in the Load event:         Dim mHidden As New WebControls.HiddenField        Me.Controls.Add(mHidden) but the control is not created. Why?Dimitris PapadimitriouSoftware Development Professional Hi,Child controls on Button do not make much sense (how would you expect them to be rendered, doesn't button allow only text into value attribute?). Button allows child controls to be added, but they won't be rendered because Button's Render(), inherited from WebControl, calls RenderBeginTag(), RenderContents() and RenderEndTag(). RenderContents() is overridden so that it does nothing.Button renders as <input type=button> and it is not required to have even closing tag (with ASP.NET 2.0 and XHTML case if of course different)Thanks,Teemu KeiskiFinland, EU I AM using ASP.NET 2. Forgot to mention. So... how can I make my control to add an extra control apart from the one being inherited? Dimitris PapadimitriouSoftware Development Professional Makes no difference to the functionality. It's the same with v2, just that there's adapters yet involved however the calls go the same route. Can you describe why do you need to inherit a Button while adding also child controls? Couldn't you inherit from a WebControl (create a pure composite one), where you'd use Button as one child control?Than...

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...

Custom Web Control inside another Custom Web Control
Hi I created a custom web control (CusWebNew) that displays some textboxes by adding them to the ControlCollection of the webcontrol. I also created a custom webcontrol (CustWebButton) that inherts from Button control, and overrided the OnClick function. When I use CustWebButton on a regular web form, it seems to function correctly. However, when I added to be part of the ControlCollection of CustWebNew, it stops to work.   Any ideas why? Thanks Hey, What do you mean by stops to work?  Explain what you are trying to do with it and what it doesn't do.Brian"Trust in the...

Web Server Control Containing another Web Server Control?
I'm building a web server control that needs to include functionality from 3rd party web server control, ASPNetMenu. My web server control needs to render ASPNetMenu at runtime to create a menu. I'd like to do this so that my control's parent ASPX page does not need to register ASPNetMenu or make any configuration changes as this should be done through my web server control. Does anybody have any suggestions on how to do this? Mike - Cache entire web sites at the client and server and keep cache current. Cache just got easier! There are two articles that you would want to be int...

How can I control load sequence of web controls in a web page?
Hi, How can I control load sequence of web controls in a web page? Thanks. For the most part, the load sequence on a web page is not relevant since all controls must be present before the page can be used. Could you provide more information as to what you're trying to do?Christopher Reed"The oxen are slow, but the earth is patient." Hi, As far as I know, we have no luck to control the load order of the Web controls on a page. However, if we need to load some controls under given conditions, we can achieve this by adding them dynamically instead.Forward SunMicrosoft Online Community Support Please remember to mark the replies as answers if they help and unmark them if they provide no help....

when loading a previously created record on to form, some controls are missing values(controls are depended on values selected in other controls)
Hello - I have created a page for Editing records.  this page will open up a chosen record and allow user to edit the data.On the form, I have 3 drop down lists.   The second dropdown list should fill values depending on value chosen in first dropdown list.  The third dropdown list should show/fill values depending on value chosen in second dropdown list.So taking this into count, i have several records with various data.  When I open-up/load a record in Edit form, only the first dropdown list has a value selected that was the pre-existing va...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

web controls and web user control
i have a problem in a web form , I have a webform that contains a web user control which in turn contains a html input form ,the web control events don't fire up ,When I click button ,no effect ,I don't know what is the effect of the html form which is in the web user control on the web controls in the web form ?? can any one help me the web control event should be handle in the code behind page, is the event handler for the button you are clicking registered? You can try double clicking the button, should give you the default btn_click event handler in code behind. Also, make ...

Use Web Control In a Web Control
Is this possible?I am working with an aspx page that consists of many different web controls.One of the web controls contains search criteria.  One of the criteria is a date range where I am trying to add a popup calendar --> which is another web controlCan I register the popupcaledar control on the questionaire control?  I have tried, but nothing seems to be registered.Any ideas will GREATLY help.Relax and have some Home Brew!Prosecute the Owner - Don't PERSECUTE the Breed!Breed Specific Legislation targets the WRONG end of the LEASH! Without seeing your code we can'...

How to access a user control from another user control in a Wizard control
My page has a wizard control and each step is a user control.  I could find the value of a control in step1 user control in the wizard page but not in step2 user control.From wizard.aspx.vb – it worksDim m_title As DropDownList = CType(Me.PersonalBox1.FindControl("ddlTitle1"), DropDownList) Question:How can I find the value of a control(textbox or dropdownlist)in step1 user control from step2 user control? I want to find “PersonalBox1.FindControl("ddlTitle1")” from Step2 AddressBox1. I have tried several ways to access it but no luck. From AddressBox.ascx.vb –...

User Control and Controls in another web page
Hi everyone, Could anyone could help me? I am using a user control called "Menu" and inside this Control there is a button Called "Update". I added this Control in my webpage say "webPage1" , when i press on the button "Update" i make an instance from my webPage and Call a function called "Update" from webpage1, inside this function i collect all the text field and droplist values to insert it in the update statement But the Problem is that text fields=Nothing is there is something i should do on the user control or web page ...

HTML Controls vs Web Form Controls
Hi, I have a page with both controls (HTML and Web Form Controls). I am trying to use an html Calendar control and then get the date selected by the user and put into a Web form input field control. When I try to run this the HTML control cannot talk to the Web form control. Any ideas? Thanks. Can't you put some javascript in the HTML-control with which you assign the value to the ASP.NET Server control? Please post some code so I can help u. Kind Regards,ThaYoung1! Hi here is the Code. Also I added a web form text input control and an html text control and created a fu...

Add .Net Control to Web Custom Control
 I want to add .NET Control (like: TextBox, Button...) to Web Custom Control.How i can do it? Alphavn That's called a composite control -- "Mark As Answer" if my reply helped you -- Hello Guys What gunteman said, that is one approach and in most cases the right one.But its also possible to add child controls to a Control thats inherit from WebControl itself. Be sure to implement INamingContainer to that inherited Control too, thats the important point of that approach.--Microsoft MVP - Visual Developer ASP / ASP.NET- http://www.aspnetzone.de/blogs/peterbuch...

Web form Controls vs HTML controls
Hi, can anyone explain me the difference between Web Form Controls and HTML controls? What is their usability and disadvantages? Can i write code behind HTML controls?    Thanx in advance. Yes, you just have add "runat=server", in your HTML control. The Web Server Control, have more funtionality that the HTML controls. With Web Server Control, you can work easy with Data. Too, you have controls as AdRotator, WebCalendar and more... : http://samples.gotdotnet.com/quickstart/MCP Sergio Tarrillo Here are the Recommendations from Microsoft ....when to use 1 over the other...

Web user control inside update panel replace with another web user control
 Hi there. I have a page with a menu. an and then the content. My thing is. That i have the update panel, and inside that i have a regual panel in which i add the Web User Controls i need. Which all works fine. My problem is. That i i have a submit funcion on almoast all the Web User controls. What i would like is that i inside that update panel, can dispose the original Web user Control and then add a response Web User Control. In normal language. Is there a way that i can load one web user control into antoher and then disposose the original? Thanks in advance hello. well, what ...

Updating a Label control in one user control from another user control
Hi all, I have a main page in my music store site that has 5 user controls on it with 1 always showing main content and the others being things like a shopping cart, "best sellers", genre list etc (a la amazon). From the main content control I want to be able to set some label controls in my shopping basket control but I just can't seem to work out the syntax for how to do this: Here's the code I'm using - I'm trying to go to the 4th user control on the page (my shopping basket) then find the appropraite label, cast it locally as a Label then update the value: Label _so...

To access a control placed in a web user control which is loaded during page load in button click event
How can I access a control in a web user control in a button click event , the user control is loaded in page load.Thanks & Regards,Abhiram Reddy Mekha. Try checking this... http://microsoft.apress.com/asptodayarchive/73869/event-handling-between-custom-user-controls-that-are-loaded-at-run-time http://aspalliance.com/565_Dynamic_Loading_of_ASPNET_User_Controls http://www.beansoftware.com/ASP.NET-Tutorials/Controls-Run-Time.aspx http://stackoverflow.com/questions/92792/user-control-created-dynamically-not-able-to-handle-events-on-postback http://www.codersource.net/asp_net_user_c...

Trying to pass values from one control to another control
I have 2 controls on my page. CaseList and Email Reviwer. CaseList contain a datagrid that when the button (5th column) is clicked 2 values should be passed to the email revier control. In the email Reviwer Control I have declared: I have: public void sendCaseIdCatId(int catid,int caseid) { ViewState["EmailReviewerCategoryId"] = catid; ViewState["EmailReviewerCaseid"] = caseid; } in my EmailReviwer control   I tried: //Display the email reviewer panel EmailCaseReviewer.Visible=true; string strcatid = e.Item.Cells[1].Text.ToString(); string strcaseid = e.Item.Cells[0].Text.T...

Web resources about - Trying to load a control into a control from another control - asp.net.web-forms

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Botvat Connected is the first robo-cleaner you can control with your Apple Watch
Let’s face it, a robot vacuum cleaner is fairly hi-tech, but these days we want more. Like the ability to start and stop cleaning cycles with ...

Qualcomm Still A Buy On Cost Controls, Growing Margins: Canaccord
... is “impressed with the long-term technical roadmap” for Qualcomm, and applauds management for its focus on streamlining the business and controlling ...

The Oscars had the lowest ratings in years, and ABC is trying to get control to revamp them
After Sunday’s Oscars brought in the lowest ratings in eight years , the top brass at ABC is ready to have more control. The network — which ...

FDA strengthens warning on birth control implant
"Black box" warning will be placed on the Essure implant, but some women say that doesn't go far enough

In control: How to harness the power of your emotions – and play each of your 34,000 emotional states ...
Scientists have known for years that emotions impair our decision-making ability.

Moderates gain control in Iran
The vote would provide a boost for President Rouhani's efforts to strengthen ties with the West, reports USA Today.

Limbaugh: Trump Is ‘Only Possibility Of Wresting Control Of The Country Back From The Upper Class’
Limbaugh: Trump Is ‘Only Possibility Of Wresting Control Of The Country Back From The Upper Class’

Control the sea in Europa Universalis IV expansion
... up in the hood now, man. This map's sparkling like never before. The latest Europa Universalis IV expansion opens up the briny deep to control...trade ...

My resignation will not affect my control in Force India, says Vijay Mallya
My resignation will not affect my control in Force India, says Vijay Mallya - Nothing has changed at Force India: Mallya

Resources last updated: 3/2/2016 7:21:28 PM