473,657 Members | 2,556 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to load different user control - Call made from control being replaced

I need to replace a user control on a page with a different user control.
The challenge I'm faced with is that this call is being made from the user
control being replaced.

Normally I replace one user control with another user control like this
'Using vb.net 1.1

ctl = LoadControl(ctl Path)
Me.cellControlH older.Controls. Clear()
Me.cellControlH older.Controls. Add(ctl)
However, here's the unique scenario I'm working with now: The main (parent)
page is default.aspx and in Me.cellControlH older (in default.aspx) I've
loaded ShoppingCart.as cx. Now in the shoppingcart control a user clicked on
a the checkout button and in that onclick event I found that the user hasn't
logged in yet. So now I want to replace the shopping cart user control with
the Login.ascx user control. But keep in mind that this code is running in
the shopping cart control. In an nutshell I need to call a method from in
the shoppingcart control to its parent (default.aspx) and this method will
run this:

ctlPath="blabla bla/Login.ascx"
ctl = LoadControl(ctl Path)
Me.cellControlH older.Controls. Clear()
Me.cellControlH older.Controls. Add(ctl)

Any great ideas on how to do this?

--
mo*******@nospa m.com
Nov 18 '05 #1
1 3585
This trick has a pretty good success rate. If I can't figure out something
even if my life depened on it, post a question to the user groups and it
will automaticly come to my mind. I figured it out and here' how:
'Note: this code is running in the shoppingcart user control and is located
in a table cell called "cellControlHol der"on the default page.
Dim ctlHolder As Control
Dim ctl As UserControl

Dim ctlPath As String = "Login.ascx "
ctlHolder = Me.Parent ' me.parent is "cellControlHol der"

ctl = LoadControl(ctl Path)
ctlHolder.Contr ols.Clear()
ctlHolder.Contr ols.Add(ctl)

--
mo*******@nospa m.com
"moondaddy" <mo*******@nosp am.com> wrote in message
news:e2******** ******@TK2MSFTN GP11.phx.gbl...
I need to replace a user control on a page with a different user control.
The challenge I'm faced with is that this call is being made from the user
control being replaced.

Normally I replace one user control with another user control like this
'Using vb.net 1.1

ctl = LoadControl(ctl Path)
Me.cellControlH older.Controls. Clear()
Me.cellControlH older.Controls. Add(ctl)
However, here's the unique scenario I'm working with now: The main (parent) page is default.aspx and in Me.cellControlH older (in default.aspx) I've
loaded ShoppingCart.as cx. Now in the shoppingcart control a user clicked on a the checkout button and in that onclick event I found that the user hasn't logged in yet. So now I want to replace the shopping cart user control with the Login.ascx user control. But keep in mind that this code is running in the shopping cart control. In an nutshell I need to call a method from in
the shoppingcart control to its parent (default.aspx) and this method will
run this:

ctlPath="blabla bla/Login.ascx"
ctl = LoadControl(ctl Path)
Me.cellControlH older.Controls. Clear()
Me.cellControlH older.Controls. Add(ctl)

Any great ideas on how to do this?

--
mo*******@nospa m.com

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
21639
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid. Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
6
2949
by: MooreSmnith | last post by:
When I navigate to the next page using Response.Rediect("MyNextPage.aspx") current page Page_Load event is called. What I may wrongly understood is that post back will happen whenever there is any server side event happens, resulting in Page_load event. Page_Load is also happening when I navigate to the next page. That means Page_load will always happen when I navigate to the next page. Please correct me If I have totally misunderstood...
1
6270
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a variable (targetId) in to the usercontrol (IntergySite.aspx) by calling its setter method. Currently, I am using if-then-else and hardcoded the User Control Object to do casting and call the setter method. Question: Is there any way I could load,...
2
4628
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation for me! I apologize for the length of this posting, but I wanted to make sure that I get an answer other than "Hey man, just use LoadControl!", because this is not what I want. The Task: Isolate a collection of web forms which are created as
4
9076
by: C M Shaw | last post by:
I have a form which I want to show modally; it's a fairly old form that's been ported up several versions of VB, and I'd like to keep its rewriting to a minimum. Basically, it is used in this sequence: 1. The form is shown. The Form_Load event does some initialization. 2. Further parameters are passed to this form. 3. We actually need this form to be modal, so we hide it and show it again modally. 4. Stuff happens on the form based...
6
4720
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload the existing user control and load the newly selected one is pretty bulky. Every time we add a new user control to the project, we have to add some code in the section where we are loading/unloading. Is there a more dynamic, more efficient way to...
3
1994
by: Ronald S. Cook | last post by:
I lost my last post, but I'm looking for a better way to manage loading user controls (that are essentially forms) in a Windows app. In my current design, I have a ListBar in which the user selects an item. I then call a sub to loop through and remove any user control that may exist in the panel. But then I have a wordy select statement to load up the user control selected. Isn't there a better way?
2
1709
by: robert112 | last post by:
This is quite a hard one guys. ***Some necessary back ground Info*** I have an asp.net 1.1 application that uses a WYSIWYG to return some html created by the user in the admin section of the application. The html that the user creates is a survey or form made up of textbox's, radio buttons and drop downs. The form gets saved to a sql database which then can be viewed on the front end of the application. The way I do this is have a label...
0
983
by: joeller | last post by:
I need to dynamically load controls and access the methods and property of the control from the page. I need to load a different control depending on a selection made by the user. I have buttons on the page whose click events call methods on the controls that process the data selected by the user. I thought I could register one control on the page then call usercontrol.LoadControl(path) to redirect the registered control to a different ascx...
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.