Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RE: VS Designer inadvertently changes control declarations in code-beh

Reply
Thread Tools

RE: VS Designer inadvertently changes control declarations in code-beh

 
 
=?Utf-8?B?WXVyaSBWYW56aW5l?=
Guest
Posts: n/a
 
      07-22-2004
In addition I would like to mention that the System.UI.Web.UserControl class has FindControl(string ControlID) Method which returns a Child Control as publicly accessible, except you have to cast it to use it and it is ugly. Compare:

this.pnlTypes.Visible = false;

vs.

((Panel)FindControl("pnlTypes")).Visible = false;

Sometimes I prefer the 2nd method, other times the 1st, but the bottom line is I should have freedom of choice.




"Yuri Vanzine" wrote:

> I think what I am about to describe is a VS.NET 2003 bug. In my project I am deliberately breaking the debatable Demeter principle http://www.c2.com/cgi/wiki?LawOfDemeter in effort to provide a degree of flexibility in control access from page level.
>
> My Project class hierarchy includes several user controls (.ascx), inherited from a certain BaseUserControl, which are reused throughout different pages(aspx).
>
> I need individual web control access on an ascx from aspx pages, therefore I declare them public in ascx.cs like this:
>
> public Panel pnlType;
> public Panel pnlStatuses;
> public Panel pnlMeters;
> public Panel pnlInstrumentDates;
> ...
>
> I can later on access these panels from aspx.cs code-behinds like this:
>
> this.pnlTypes.Visible = false;
>
> Therefore I need them public through a conscious choice of mine. However, I am facing the following problem:
>
> When I open my ascx control in VS Designer, it changes the control declarations from public to protected in ascx.cs code-behind, thus forcing me into Law of Demeter.
>
> I can submit to LoD and the stubborn will of VS.NET Designer and instead set up a public accessor for all my protected members, but I still would like to find a way to make public declarations work w/o VS Designer breaking them.
>
> I end up undoing the changes that VS Designer forces upon me every time it changes my control code-behind, but my ultimate question is why should VS.NET IDE change my code at all?
>
> Thank you,
>
> Yuri Vanzine

 
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
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Building Controls 3 07-30-2007 09:09 PM
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Web Controls 0 07-21-2007 12:58 AM
Sharepoint Designer/ Expression Web Designer : adding item in toolbox ? Steve B. ASP .Net 4 06-01-2007 04:29 AM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
DropDownList.SelectedValue resets inadvertently =?Utf-8?B?cmVuZ2VlazMz?= ASP .Net 3 12-22-2005 02:40 PM



Advertisments