I am trying to access a user control class, for a user control that is
loaded dynamically, from the containing page. I have been able to access Web
controls in the user control, but so far I have been unable to expose the
user control class itself. I'm guessing that I need to set up an interface,
but I am not sure how to accomplish this.
Here is the code that loads the user control:
protected void Page_Init(object sender, EventArgs e)
{
UserControl bottomPanel = (UserControl) LoadControl("~/Reviews.ascx");
bottomPanel.ID = "Reviews_ascx";
PlaceholderUserControl.Controls.Add(bottomPanel);
}
----
Here is how I access Web controls in the user control:
PlaceholderUserControl.Controls[0].FindControl("radReview");
----
I need to set a property of the user control for data access, but this is a
far as I've been able to go.
--
Regards,
Fred Chateau
fchateauAtComcastDotNet 3 1909
Fred,
Usually user controls (as well as web controls) do not expose internal
control structure, but rather public properties/methods that allow
manipulating them - the internal structure of the controls should not be
known or relied upon by the consumers.
"Fred Chateau" wrote:
I am trying to access a user control class, for a user control that is
loaded dynamically, from the containing page. I have been able to access Web
controls in the user control, but so far I have been unable to expose the
user control class itself. I'm guessing that I need to set up an interface,
but I am not sure how to accomplish this.
Here is the code that loads the user control:
protected void Page_Init(object sender, EventArgs e)
{
UserControl bottomPanel = (UserControl) LoadControl("~/Reviews.ascx");
bottomPanel.ID = "Reviews_ascx";
PlaceholderUserControl.Controls.Add(bottomPanel);
}
----
Here is how I access Web controls in the user control:
PlaceholderUserControl.Controls[0].FindControl("radReview");
----
I need to set a property of the user control for data access, but this is a
far as I've been able to go.
--
Regards,
Fred Chateau
fchateauAtComcastDotNet
That is exactly what I am trying to do. I want to expose the user control's
internal properties as public properties of the user control class, but I do
not know how to get a reference to the user control class from the
containing page. I can get a reference to the Web controls in the user
control, but after exposing public properties of the Web controls in the
user control class, how do I get a reference to the user control class
itself?
--
Regards,
Fred Chateau
fchateauAtComcastDotNet
"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e
in message news:46**********************************@microsof t.com...
Fred,
Usually user controls (as well as web controls) do not expose internal
control structure, but rather public properties/methods that allow
manipulating them - the internal structure of the controls should not be
known or relied upon by the consumers.
"Fred Chateau" wrote:
>I am trying to access a user control class, for a user control that is loaded dynamically, from the containing page. I have been able to access Web controls in the user control, but so far I have been unable to expose the user control class itself. I'm guessing that I need to set up an interface, but I am not sure how to accomplish this.
Here is the code that loads the user control:
protected void Page_Init(object sender, EventArgs e) { UserControl bottomPanel = (UserControl) LoadControl("~/Reviews.ascx"); bottomPanel.ID = "Reviews_ascx"; PlaceholderUserControl.Controls.Add(bottomPanel ); }
---- Here is how I access Web controls in the user control:
PlaceholderUserControl.Controls[0].FindControl("radReview");
----
I need to set a property of the user control for data access, but this is a far as I've been able to go.
-- Regards,
Fred Chateau fchateauAtComcastDotNet
I found it. I needed to add the <%@ reference control="~/ControlName.ascx"
%directlve to the page.
--
Regards,
Fred Chateau
fchateauAtComcastDotNet
"Fred Chateau" <fc******@127.0.0.1wrote in message
news:ee**************@TK2MSFTNGP03.phx.gbl...
That is exactly what I am trying to do. I want to expose the user
control's internal properties as public properties of the user control
class, but I do not know how to get a reference to the user control class
from the containing page. I can get a reference to the Web controls in the
user control, but after exposing public properties of the Web controls in
the user control class, how do I get a reference to the user control class
itself?
--
Regards,
Fred Chateau
fchateauAtComcastDotNet
"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com>
wrote in message
news:46**********************************@microsof t.com...
>Fred,
Usually user controls (as well as web controls) do not expose internal control structure, but rather public properties/methods that allow manipulating them - the internal structure of the controls should not be known or relied upon by the consumers.
"Fred Chateau" wrote:
>>I am trying to access a user control class, for a user control that is loaded dynamically, from the containing page. I have been able to access Web controls in the user control, but so far I have been unable to expose the user control class itself. I'm guessing that I need to set up an interface, but I am not sure how to accomplish this.
Here is the code that loads the user control:
protected void Page_Init(object sender, EventArgs e) { UserControl bottomPanel = (UserControl) LoadControl("~/Reviews.ascx"); bottomPanel.ID = "Reviews_ascx"; PlaceholderUserControl.Controls.Add(bottomPanel) ; }
---- Here is how I access Web controls in the user control:
PlaceholderUserControl.Controls[0].FindControl("radReview");
----
I need to set a property of the user control for data access, but this is a far as I've been able to go.
-- Regards,
Fred Chateau fchateauAtComcastDotNet This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alphonse Giambrone |
last post by:
I have a web form with 2 user controls on it (UC1 and UC2).
Each control has a bound datagrid with textboxes in the footer to add a new
row. There are also requiredfieldvalidators in each footer....
|
by: trinitypete |
last post by:
Hi all,
I have a user control that uses control literal to build
a heading with a link, and a div containing links below.
As the link heading is hit, I want to change the style of
the div,...
|
by: Jo Inferis |
last post by:
Disclaimer : I'm fairly new to .NET (about 4 weeks and counting now...)
I have a page which contains multiple user controls, some of which it has
access to the methods of (by making the controls...
|
by: guoqi zheng |
last post by:
In a regular html form, when user press "enter" key, the form will be
submitted.
However, in ASP.NET web form, a form will only be submitted (post back) when
a special button is clicked. Many...
|
by: louise raisbeck |
last post by:
Resending this as own topic as didnt get answer from original. Would be
grateful for a response from anyone that knows. Thanks.
Hi there, I found your post really helpful..but i wondered if, once...
|
by: Mr Newbie |
last post by:
Hi There,
Here I am messing about with User Controls and I seem to have a conundrum on
my hands which I'm sure you chaps will unravel for me in the blink of an
eye.
|
by: Efi Merdler |
last post by:
Hi,
I created a user control, but instead of handling exception in the
user control level I prefer to handle them in the containing form.
In the load event of the containing form I'm using:...
|
by: Fred Chateau |
last post by:
I am trying to reference a server control in a user control, from the
containing page. Is there a way to do that? I have tried
"UserControl1.FindControl("ControlName")" but I get a null reference....
|
by: Fred Chateau |
last post by:
I am trying to access a user control class, for a user control that is
loaded dynamically, from the containing page. I have been able to access Web
controls in the user control, but so far I have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
|
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,...
| |