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(objec t sender, EventArgs e)
{
UserControl bottomPanel = (UserControl) LoadControl("~/Reviews.ascx");
bottomPanel.ID = "Reviews_as cx";
PlaceholderUser Control.Control s.Add(bottomPan el);
}
----
Here is how I access Web controls in the user control:
PlaceholderUser Control.Control s[0].FindControl("r adReview");
----
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
fchateauAtComca stDotNet 3 1924
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(objec t sender, EventArgs e)
{
UserControl bottomPanel = (UserControl) LoadControl("~/Reviews.ascx");
bottomPanel.ID = "Reviews_as cx";
PlaceholderUser Control.Control s.Add(bottomPan el);
}
----
Here is how I access Web controls in the user control:
PlaceholderUser Control.Control s[0].FindControl("r adReview");
----
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
fchateauAtComca stDotNet
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
fchateauAtComca stDotNet
"Sergey Poberezovskiy" <Se************ *****@discussio ns.microsoft.co mwrote
in message news:46******** *************** ***********@mic rosoft.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(objec t sender, EventArgs e) { UserControl bottomPanel = (UserControl) LoadControl("~/Reviews.ascx"); bottomPanel. ID = "Reviews_as cx"; PlaceholderUse rControl.Contro ls.Add(bottomPa nel); }
---- Here is how I access Web controls in the user control:
PlaceholderUse rControl.Contro ls[0].FindControl("r adReview");
----
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 fchateauAtComc astDotNet
I found it. I needed to add the <%@ reference control="~/ControlName.asc x"
%directlve to the page.
--
Regards,
Fred Chateau
fchateauAtComca stDotNet
"Fred Chateau" <fc******@127.0 .0.1wrote in message
news:ee******** ******@TK2MSFTN GP03.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
fchateauAtComca stDotNet
"Sergey Poberezovskiy" <Se************ *****@discussio ns.microsoft.co m>
wrote in message
news:46******** *************** ***********@mic rosoft.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(objec t sender, EventArgs e) { UserControl bottomPanel = (UserControl) LoadControl("~/Reviews.ascx"); bottomPanel.I D = "Reviews_as cx"; PlaceholderUs erControl.Contr ols.Add(bottomP anel); }
---- Here is how I access Web controls in the user control:
PlaceholderUs erControl.Contr ols[0].FindControl("r adReview");
----
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 fchateauAtCom castDotNet 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.
When I try to add a new row to UC1 the requiredfieldvalidators for UC2 fire
and therefore the page is not posted.
If I remove one control, everything works fine.
I have 2 questions.
1. How can I get the validators for each control to only...
|
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, making it visible or not. Yep you guessed it,
expanding tree type functionality.
The header has an onclick event onclick='Doexpandcollapse
|
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 inherit from a generic
pre-compiled class). I want the containing page to read the value returned
by one of the control methods and depending on the value, either show or
hide a different control.
I initially tried to put this check in the...
|
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 user get used to click "enter" key to
submit a form. How can I use "enter" key to submit/postback in ASP.NET.
Thank,
Guoqi Zheng
|
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 I have
exposed a public property containing the value of a textbox in a user
control..how do I grab this from the calling page? I cant think of the
syntax, since my page doesnt know the contents of the class (and therefore,
the public...
| |
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:
entryWindow.Error += new EventHandler(Page_Error);
when entryWindow is my user control.
Two questions:
|
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.
--
Regards,
Fred Chateau
fchateauAtComcastDotNet
|
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 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)...
|
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,...
|
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: 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: 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...
|
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |