Welcome Guest Search | Active Topics | Sign In | Register

Create a new User Control based on a Parent User Control by Inheritance. Options
tarekahf
Posted: Saturday, May 22, 2010 4:15:29 AM

Rank: Advanced Member
Groups: Member

Joined: 3/27/2010
Posts: 48
I know maybe this question is not directly related to support for EO.Web Grid, but I will post this question just in case I will get some help.

I created a Web Project, and a complex Web User Control "UC1".

This "UC1" has a ASP.NET DetailsView and a Grid Control EO.Web Grid "EO_Grid". Everything works fine.

I want to build another UC2 which will inherit all the features of UC1, but, it will overried or replace "EO_Grid" with a standard GridView Control. This is becuase UC1 has a lot of functionality that I want to avoid using Copy/Past to replicate them in UC2.

In other words, I want UC2 to work as if "EO_Grid" does not exisit or "deleted", becuase it has some licensing reuqirements, and I want the end user to choose what option he wants:

1. Work with UC1 which required a license,

or

2. Work with UC2 which does not require a license.

I need to implement the above logic as a Temporary Solution until I get the approval to use EO.Web in our organization.

Now, the EO.Web DLL is displaying wraning message about license, and I think it will stop the page from working if the license is expired. I have already deployed the application LIVE, and I need to implement this "trick" so that the application work without interruption.

How I can implement this requirement ?

Tarek.
eo_support
Posted: Sunday, May 23, 2010 8:05:39 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I can't see anything special in this case. You would basically change your code to work with both user controls. There is no trick or shortcut I can think of.

Thanks!
tarekahf
Posted: Sunday, May 23, 2010 8:20:09 AM

Rank: Advanced Member
Groups: Member

Joined: 3/27/2010
Posts: 48
eo_support wrote:
Hi,

I can't see anything special in this case. You would basically change your code to work with both user controls. There is no trick or shortcut I can think of.

Thanks!

The part which makes this tricky, is that User Controls have 3 parts: Source (Markup), Designer Generated Code, and custom Code-Behind.

I can create a new UC2 which will inherit UC1. In UC2, I copy/past the markup from UC1 to UC2 and delete EO_Grid Markup, and replace it with ASP.NET GridView. In other words, UC2 is same as UC1 but the EO.Web Grid must be replaced with ASP.NET GridView, and the Control ID must be the same, becuase most properties/methods do exist in both controls, and most code can be reused.

Actually, it worked, but not directly. I had to do some small tricks to make it work, beucase EO.Web Grid cannot be converted to ASP.NET GridView, which was the main problem. In UC2 I must remove all reference to EO.Web Dll.

I think I am nearly 80% done.
eo_support
Posted: Sunday, May 23, 2010 8:39:00 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
tarekahf wrote:
beucase EO.Web Grid cannot be converted to ASP.NET GridView, which was the main problem. In UC2 I must remove all reference to EO.Web Dll.


That's precisely where the problem is. These are two totally different controls that require different code. If you wish to work with both, you code for both. There is no such thing as just replacing one with another just by keeping the same ID. Compiler simply won't take it.
tarekahf
Posted: Sunday, May 23, 2010 9:06:51 AM

Rank: Advanced Member
Groups: Member

Joined: 3/27/2010
Posts: 48
So, what I did ? I defined the control as "Object" in code ! And, I use "if typeof ... is ... then" to check for special cases.

That is the whole purpose of OOD/OOP ... code reusability.

Tarek.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.