Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accesss User Control Class From Containing Page

Reply
Thread Tools

Accesss User Control Class From Containing Page

 
 
Fred Chateau
Guest
Posts: n/a
 
      08-08-2007
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=
Guest
Posts: n/a
 
      08-08-2007
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
>
>
>

 
Reply With Quote
 
 
 
 
Fred Chateau
Guest
Posts: n/a
 
      08-08-2007
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" <(E-Mail Removed)> wrote
in message news:(E-Mail Removed)...
> 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
>>
>>
>>



 
Reply With Quote
 
Fred Chateau
Guest
Posts: n/a
 
      08-08-2007
I found it. I needed to add the <%@ reference control="~/ControlName.ascx"
%> directlve to the page.

--
Regards,

Fred Chateau
fchateauAtComcastDotNet


"Fred Chateau" <fchateau@127.0.0.1> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)>
> wrote in message
> news:(E-Mail Removed)...
>> 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
>>>
>>>
>>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting value of user control from its containing page. archana ASP .Net 2 05-24-2007 05:02 AM
problem with user control containing GridView control and paging... John Smith ASP .Net 0 08-02-2006 09:18 PM
Connecting Accesss to ASP Des ASP General 2 01-09-2006 11:54 PM
accesss denied on downstairs computer. what is node type "hybrid" =?Utf-8?B?S3VlMg==?= Wireless Networking 1 06-30-2005 02:30 PM
Subclassing a user control containing UI elements Charlie@CBFC ASP .Net 1 04-26-2005 01:57 PM



Advertisments