Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

UserControl reference problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mAbZ - 19 Jul 2007 10:34 GMT
I neeed to instantiate an UserControl in an aspx page like this:

<MyNamespace:MyControl ID="ctrl1" runat="server" MyParent="<%# this %>" />

where "this" is the current aspx page and should be assigned to
property Parent contained in MyControl  class.
Above code is contained in a PlaceHolder.

When debuging, "this" is not null (obviously) but
value in MyParent property's setter is null.
So the reference is not beaing passed.

What am I missing??
I could set this value in OnDataBind but don't know how to get it there from
the aspx page.

I've been reading a number of tutorials on DataBinding, but not found any
solution to this.
Please, help!
bruce barker - 19 Jul 2007 16:59 GMT
the Page class does not support databind, so your control has to be
contained in one that does, Repeater, GridView, FormView, etc. then in
the codebehind, you need to call DataBind() on the parent control.

a better approach then using a databinding expression when you are not
using databind, would be to re-engineer MyParent to MyParentID. then you
would just set the parent name in the aspx. in the control code recurse
thru control.Parent.FindControl(parentName) to get the actual control.
if you just want the Page (this), every control has a Page property that
is the Page.

-- bruce (sqlwork.com)

> I neeed to instantiate an UserControl in an aspx page like this:
>
[quoted text clipped - 15 lines]
> solution to this.
> Please, help!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.