Search:
Namespaces
Discussions
.NET v1.1
Feedback
Simple User Control question...
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngvs' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Michael R Kizer
I'm sure this is a simple question, but I haven't been able to locate a
good answer for it yet...
Let's say I have a User Control used for navigation that contains a series
of image buttons.
This User Control exists on every page for the website, but on certain
pages I wish to disable or hide some of the buttons.
How do I reference the properties of controls within a User Control from
the Page_Load event?
Thanks,
~Michael Kizer
Click here to reveal e-mail address
Reply to this message...
James Shaw (VIP)
Add a property to your UC, then set that in your pages Page_Load or in HTML
directly, like this:
(this is slightly weird in the way that I pass bools as strings, but it
allows use of the property in HTML as well as code)
// user control:
public abstract class myUC : System.Web.UI.
UserControl
{
protected
ImageButton
myButton;
public string ButtonOn
{
set { myButton.Visible = bool.Parse(value); }
}
}
// page (method 1, in HTML)
<%@ Register TagPrefix="MyStuff" TagName="MyUC" Src="UserControls/MyUC.ascx"
%>
<MyStuff:MyUC runat="server" ButtonOn="false" />
// page (method 2, in Page_Load)
using MyStuff;
public class Default : Page
{
protected MyUC myUC;
private void Page_Load(object sender, System.
EventArgs
e)
{
myUC.ButtonOn = false.ToString();
}
}
James Shaw
http://CoverYourASP.com/
Download it. Run it. Learn it.
http://ASPRSS.com/
Publish ASP with RSS XML
-----Original Message-----
From: Michael R Kizer [mailto:
Click here to reveal e-mail address
]
Sent: Monday, August 12, 2002 7:26 PM
To: aspngvs
Subject: [aspngvs] Simple User Control question...
I'm sure this is a simple question, but I haven't been able to locate a
good answer for it yet...
Let's say I have a User Control used for navigation that contains a series
of image buttons.
This User Control exists on every page for the website, but on certain
pages I wish to disable or hide some of the buttons.
How do I reference the properties of controls within a User Control from
the Page_Load event?
Thanks,
~Michael Kizer
Click here to reveal e-mail address
| [aspngvs] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvs.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
System.EventArgs
System.Web.UI.UserControl
System.Web.UI.WebControls.ImageButton
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com