web user control

  • Thread starter Thread starter Nedu N
  • Start date Start date
N

Nedu N

Hi,

I have got bunch of controls on my user contro .ascx file, i am trying to
make those child control to public, but i see the public keywords kepp
changing back to protected everytime. I remember i did something to get rid
of this some time back..could not recall how to do that...

Nedu
 
not exactly...
but it is inside the
public abstract class WebUserControl1: System.Web.UI.UserControl

{

public System.Web.UI.WebControls.Label lblFieldName; ==> all these
public controls become protected whenever i add new control to ascx....

public System.Web.UI.WebControls.Label lbl1;

public System.Web.UI.WebControls.Label lb2;


}
 
Hi Nedu,

I think this is by design.
Why you need a control reference to be public? Protected does not meet your
need?
The workaround I can find now is creating a public property which exposes
this reference.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi,
I need the controls to be declared public since i want to access them in the
other webforms wherever i am referencing these user controls. I think
protected controls can be accessible only from within the same class an
inherited classes.
Thanks
Nedu
 
Hi Nedu,

Oh, yes, I original reproduced this issue in .aspx web form, so I think it
makes no sense to expose a page's protected field as public.
But for .ascx user control, it actually makes sense.
The only workaround I can think of is creating a public property which
exposes that protected field.
I hope this makes sense to you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
It will be very helpful if the original question can be found in your post.
just a thought =)
 
Back
Top