I have a web form with 3 links, depending on which link is clicked a user
control loads, page1.ascx,page 2.ascx,page3.as cx
page1.ascx does a search, uses 3 asp:dropdownlis ts with viewstate true and
auto post back. It loads by default first time.
User clicks on link 2, page2.ascx loads after page1.ascx I need the loaded
control to go away when a different one is clicked, I have seen similar
stuff on threads but I can't understand a clear answer on what syntax and
where in the order?
I do not understand the syntax for controls.remove the sample says
control.remove where control.name =
and there is no controls.name in c sharp syntax for this? Also I am using
control array see below
private void OnPageButtonCli ck(object sender, System.EventArg s e)
{
LinkButton pageButton = (LinkButton)sen der;
string pageNumber = pageButton.ID.S ubstring("_page Button".Length) ;
ActiveTab = pageNumber;
SelectPage(page Number);
}
public void SelectPage(stri ng pageNumber)
{
Control page = LoadControl(Str ing.Format("Pag e{0}.ascx", pageNumber));
_content.Contro ls.Add(page);
LinkButton pageButton = FindControl(Str ing.Format("_pa geButton{0}",
pageNumber)) as LinkButton;
if (pageButton != null)
{
pageButton.Back Color = Color.Gold;
pageButton.CssC lass = "tabon";
}
LastActiveContr ol = page.ID.ToStrin g();
}
--
cindy mello 2 2178
I'm assuming your "_content" is a container Control. If so, try
_content.Contro ls.Clear(); before you add the next control.
"cindy" wrote: I have a web form with 3 links, depending on which link is clicked a user control loads, page1.ascx,page 2.ascx,page3.as cx
page1.ascx does a search, uses 3 asp:dropdownlis ts with viewstate true and auto post back. It loads by default first time.
User clicks on link 2, page2.ascx loads after page1.ascx I need the loaded control to go away when a different one is clicked, I have seen similar stuff on threads but I can't understand a clear answer on what syntax and where in the order?
I do not understand the syntax for controls.remove the sample says control.remove where control.name = and there is no controls.name in c sharp syntax for this? Also I am using control array see below
private void OnPageButtonCli ck(object sender, System.EventArg s e) { LinkButton pageButton = (LinkButton)sen der; string pageNumber = pageButton.ID.S ubstring("_page Button".Length) ; ActiveTab = pageNumber; SelectPage(page Number); } public void SelectPage(stri ng pageNumber) { Control page = LoadControl(Str ing.Format("Pag e{0}.ascx", pageNumber)); _content.Contro ls.Add(page); LinkButton pageButton = FindControl(Str ing.Format("_pa geButton{0}", pageNumber)) as LinkButton; if (pageButton != null) { pageButton.Back Color = Color.Gold; pageButton.CssC lass = "tabon"; } LastActiveContr ol = page.ID.ToStrin g();
}
-- cindy mello
Hi Cindy,
I've also noticed your another previous post in the
" 03 dropdownlist selectedindexch anged not firing in usercontrol on"
microsoft.publi c.dotnet.framew ork.aspnet.webc ontrols
newsgroup, I've also attached a demo package there. Have you had a chance
to test it? Also, as for the unloading usercontrol, I think we should
follow the following two steps according to my description in the former
thread:
1. In the first postback of the 3rd link(which will remove the first 2
usercontrols), we can use Container.Contr ols.Clear to clear the control
collection, we can also use Controls.Remove to remove the control instance
from it's parent collection( use FindControl to get the reference first)
2. Also, set the flag in ViewState accordingly since the sequential
postback will create dynamic controls denpending on these values.
If have anything unclear or have any problems accessing the demo pages I
attached there, please feel free to post here.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Sgier |
last post by:
Hello
I want to replace a windows bitmap load function through an equivalent
SDL function.
I should extract the img height etc. and assign it to the terrainTex
array. I've also
three beginner questions:
-Concerning that array why is texID used? terrainTex doesn't state
the first element?
What does terrainTex represent? Especially the "0".
-How do i transfer terrainTex back to the calling terrain.cpp. the
|
by: Ender |
last post by:
I have an application that I would like third party developers to be
able to create Plug-ins that will be dynamically loaded into our
application to extend functionality.
I have utilized the "Let Users Add Functionality to Your .NET
Applications with Macros and Plug-Ins" article at MSDN for the dynamic
loading of DLLs
http://msdn.microsoft.com/msdnmag/issues/03/10/Plug-Ins/default.aspx
|
by: buran |
last post by:
Dear ASP.NET Programmers,
I am loading a web user control ("taclient.ascx") into a placeholder (ID:
phFA). The web user control contains a cancel button (ID: btnCancel). I
would like to "unload" the web user control when the user clicks on the
cancel button. How can I accomplish this? Thanks in advance.
dim myControl as Control
myControl = LoadControl("taclient.ascx")
phFA.Controls.Clear()
|
by: John |
last post by:
Hi all,
I need finality on this once and for all please.
I have a main page which contains a couple of placeholders and within these
placeholders, depending on what the user presses, I load different user
controls. This loading of user controls is done within the code-behind of
the main page. The problem is that before loading a user control in place of
another, I need to do a Controls.Add then a Controls.Remove so the viewstate
is...
|
by: Mike |
last post by:
Hi,
I am strugling with a simple problem which I can't seem to resolve.
I have an asp.net page which contains a server-control (flytreeview,
which is a kind
of a tree to be exact).
The tree is being updated by some other process through remoting.
When the page loads, I init the tree, and in my browser I can see the
initialized tree.
The problem is that every time that I receive update to tree from the
remote process,
| |
by: PW |
last post by:
Hi,
This is bizarre. I've check and rechecked the spelling, cut and paste
the name of the form (when trying to rename the form) and the control
yet I still get a parameter prompt when the form runs. I've even
deleted the control and started over.
This is the code for the recordsource of the form:
"SELECT * FROM qryGuestStorePurchases_pw WHERE
|
by: adiel_g |
last post by:
I added a user control to a webform in Asp.net 2.0. I am also adding
several other user controls to this webform. Now I am trying to find
a way to stop the user controls from loading up when I call the
webform. I could possibly have 10 user controls in this page and I
would not want all of them to load up. I would like to control which
user control loads up. I have tried placing each user control in a
separate placeholder and then...
|
by: Frinavale |
last post by:
Introduction
Sometimes, when developing web applications, we need to be able to dynamically load controls based on user selections. The following article describes a simple scenario where TextBox controls need to be dynamically loaded according to user input. This simple example can be further extended to dynamically load custom web user controls.
Background
Please familiarize yourself with the ASP.NET Page Life Cycle. It is crucial to...
|
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= |
last post by:
I have a web app that when I click a menu, I load a control. On one of these
controls, I have a button that when clicked, I need to unload the control to
unload itself and load a different control in its place. I am not sure how to
do this from within a control itself. Can anyone offer any help and show me
what I am doing wrong with my code below?
//This is on one of my controls.
protected void btnSubmit_Click(object sender, EventArgs e)...
|
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...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |