StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Business Object in User ControlExpand / Collapse
Author
Message
Posted 11/06/2006 8:31:33 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 11/19/2007 4:06:18 AM
Posts: 41, Visits: 99
For making any Business Object accessible in any webpage, i inherit the webpage from ApplicationBasePage but i cant do the same with a User Control, so how can i make any business object available to my User Controls ?
Post #4152
Posted 11/06/2006 10:20:02 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 10:13:07 AM
Posts: 4,799, Visits: 4,768
You will take the same approach as the previos post I made mentioning the definition of BOs in your ApplicationBasePage.

http://forum.strataframe.net/Topic4019-8-1.aspx#bm4151 

Post #4158
Posted 11/06/2006 11:11:28 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 11/19/2007 4:06:18 AM
Posts: 41, Visits: 99
Hello Trent,

The BusinessObject works fine in an .aspx page because the aspx page is inherited from ApplicationBasePage but the user control cant refer to the same business object because it is not inherited from the ApplicationBAsePage and I dont think if it can be inherited from applicationbasepage as well. following is a code snippet from Aspx page [which works fine] and from .ascx control [which throws a compilation error since it does not know where the business object is]

Code for .ASCX [ User Control]

Partial Class ListControls_CompanyList

Inherits System.Web.UI.UserControl

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

GridView1.DataSource = oCompanyBO.GetAll("vik")

DataBind()

End Sub

End Class

Code for ASPX page inherited from ApplicationBase Page.

Partial Class List_Company

Inherits MyAppBasePage

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

GridView1.DataSource = oCompanyBO.GetAll("vik")

DataBind()

End Sub

End Class

Post #4162
Posted 11/06/2006 12:40:37 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 10:13:07 AM
Posts: 4,799, Visits: 4,768
What we always do is create a property and then set that property in the Load or the property sheet (depending on how you design it) of the page that uses the control.  This way the control is encapsulated, as it should be.

For example:

Public Property MyCustomers As CustomersBO
...
End Property

This way your control can use the BO that comes from the ApplicationBasePage by simply setting the property when the page is loaded.  Then your control will reference the property instead whenever it needs to access the BO inside of the control.

Post #4165
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 1:07pm

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.109. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.