473,725 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing a panel on a webform from an usercontrol

My question is whether it's possible to change the
properties of a panel, that resides on the webform
containing the usercontrol, in the usercontrol itself.

Like this:

<form>
<asp:panel visibility=fals e .... </asp panel>
<user:control > //a function here turns the visibilty to
true </user:control>
</form>

Greetz,

Lokhan Wong
Lo*********@hot mail.com

//cogito ergo sum

Nov 17 '05 #1
2 1811
Lokhan Wong wrote:
My question is whether it's possible to change the
properties of a panel, that resides on the webform
containing the usercontrol, in the usercontrol itself.

Like this:

<form>
<asp:panel visibility=fals e .... </asp panel>
<user:contro l> //a function here turns the visibilty to
true </user:control>
</form>

Greetz,

Lokhan Wong
Lo*********@ho tmail.com

//cogito ergo sum

This is possible:

In the usercontrol code behind I have:

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(Page.IsPostB ack)
{
// Find the control
System.Web.UI.W ebControls.Pane l ctrl =
(System.Web.UI. WebControls.Pan el) Page.FindContro l("MyPanel");

// Make it visible
ctrl.Visible = true;

// Abd Add some text
Label lbl = new Label();
lbl.Text = " Now you see me!";
ctrl.Controls.A dd(lbl);
}
}

On the aspx page containing the usercontrol:

<form id="Form1" method="post" runat="server">
<asp:panel id="MyPanel" visible="False" runat="server"> Hello</asp:panel>
<kk:MyControl id="MyControl" runat="server" />
</form>

From a design perspective I'd be wary of doing this because you are
creating a dependancy in the containing page and introducing some tight
coupling that will affect the user control's re-use in other pages..

HTH
Kev
Nov 17 '05 #2
It worked. Thanks for the info.

The reason why I used it this way is because I wanted to
make a registering page made of several steps. Putting
every step in a seperate page would be unwise. Also
putting every step in a seperate panel on the page would
make the page unmanageable. So by putting every step in
its own usercontrol I can manage the code more easily.
-----Original Message-----
Lokhan Wong wrote:
My question is whether it's possible to change the
properties of a panel, that resides on the webform
containing the usercontrol, in the usercontrol itself.

Like this:

<form>
<asp:panel visibility=fals e .... </asp panel>
<user:control > //a function here turns the visibilty to
true </user:control>
</form>

Greetz,

Lokhan Wong
Lo*********@h otmail.com

//cogito ergo sum

This is possible:

In the usercontrol code behind I have:

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(Page.IsPostB ack)
{
// Find the control
System.Web.UI.W ebControls.Pane l ctrl =
(System.Web.UI .WebControls.Pa nel) Page.FindContro l

("MyPanel");
// Make it visible
ctrl.Visible = true;

// Abd Add some text
Label lbl = new Label();
lbl.Text = " Now you see me!";
ctrl.Controls.A dd(lbl);
}
}

On the aspx page containing the usercontrol:

<form id="Form1" method="post" runat="server">
<asp:panel id="MyPanel" visible="False" runat="server"> Hello</asp:panel> <kk:MyControl id="MyControl" runat="server" />
</form>

From a design perspective I'd be wary of doing this because you arecreating a dependancy in the containing page and introducing some tightcoupling that will affect the user control's re-use in other pages..
HTH
Kev
.

Nov 17 '05 #3

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

Similar topics

4
9377
by: james | last post by:
I cannot get my UserControl's browsable properties to show up in the designer properties panel. I have then public virtual bool TestProp { {get return testProp; } set { testProp = value; } } but it doesn't show up in the designer. By the way, this used to work in the 2002 version, now in 2003 I am getting all kinds of problems like this
2
352
by: Lokhan Wong | last post by:
My question is whether it's possible to change the properties of a panel, that resides on the webform containing the usercontrol, in the usercontrol itself. Like this: <form> <asp:panel visibility=false .... </asp panel> <user:control> //a function here turns the visibilty to true </user:control>
6
11296
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
2
1392
by: Craig Douthitt via DotNetMonster.com | last post by:
I am trying to capture an buttonclick on a usercontrol in the webform the usercontrol resides in. After researching this issue, I've come to believe that the best way of handling this is by raising an event in the control and consuming the event in the webform. I tried the following, unfortunatly while the usercontrol raises the event the webform method does not react. UserControl (Named WebUserControl1 contains one button) Public...
3
3865
by: gary | last post by:
Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is located in a "/include" folder If you have a hyperlink control and you assign the navigateurl property = "../#anchor" whereby you want to add this # reference to the current url the url ends up with the #anchor twice.
1
12078
by: TheSteph | last post by:
Hi ! I would like to create a UserControl that act as a « Collapsible Panel ». So I have a UserControl with two panels : a "Header panel" at the top, and a "Container Area Panel" docked to fill the remaining client area of the
2
8620
by: Wayne Brantley | last post by:
If you expose a public property of a usercontrol that accesses an object on the user control it will give a null reference exception when you wrap that in an update panel. Others are having the same problem. Here is a complete example: http://forums.asp.net/thread/1555836.aspx Related to this: (But I am not doing dynamic user control creation) http://www.eightpence.com/null-controls-inside-of-an-updatepanel-in-aspnet-atlas/
1
7821
by: Nathan Laff | last post by:
I have a panel that I want to AutoSize with an AutoSize mode of GrowAndShrink, but I only want it to autosize vertically. Reason being I have anchors set up to a usercontrol which can resize. Any idea on how to accomplish that?
3
2971
by: zhaodapu | last post by:
I derived a panel class: public class DeskPanel : System.Windows.Forms.Panel Now I want to use the visual designer to add controls in MyPanel class. But I noticed that the visual designer didn't work. I try some other ways, and found the if i derived my panel from UserControl class it works. However, I thought deriving from Panel is more rational. I have several panels (such as calendar panel, contacts
0
8888
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
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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...
1
9174
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,...
0
9111
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
8096
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...
0
6011
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();...
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
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.