Help: User control dim changes RIGHT UNDER MY NOSE! | | |
I changed a usercontrol dim from:
Protected WithEvents ddlView As System.Web.UI.WebControls.DropDownList
to:
Public Shared ddlView As System.Web.UI.WebControls.DropDownList
I saved it SEVERAL times. It was working for about a day then, as I'm
programming today, I notice that it's changed back to the original. Any
ideas? This happened several times and each time I fix it it works fine.
Thanks in advace. | | | | re: Help: User control dim changes RIGHT UNDER MY NOSE!
this declaration was likely done by the vs.net (in other words, this is
generated code). vs.net could be the one changing it back, so you need
to find a better way to work with this control. why is it shared? maybe
using public properties to access the protected control would be better
VB Programmer wrote:[color=blue]
> I changed a usercontrol dim from:
> Protected WithEvents ddlView As System.Web.UI.WebControls.DropDownList
> to:
> Public Shared ddlView As System.Web.UI.WebControls.DropDownList
>
> I saved it SEVERAL times. It was working for about a day then, as I'm
> programming today, I notice that it's changed back to the original. Any
> ideas? This happened several times and each time I fix it it works fine.
>
> Thanks in advace.
>
>[/color] | | | | re: Help: User control dim changes RIGHT UNDER MY NOSE!
if the property is shared, the other item has to be shared. why is the
property shared? i dont get that part.
VB Programmer wrote:[color=blue]
> Thanks. I tried this:
>
> Public Shared Property ddlMyView() As DropDownList
> Get
> Return ddlView
> End Get
> Set(ByVal Value As DropDownList)
> ddlView = Value
> End Set
> End Property
>
> But, I get a squiggly under the ddlView and it says 'Cannot refer to an
> instance member of a class from within a shared method or a shared member
> initialize without an explicit instance of the class'.
>
> Any more ideas? Thanks!
>
> "Kairi Zikpin" <zikkai.nospam.@netscape.net> wrote in message
> news:3F01D8EA.8060509@netscape.net...
>[color=green]
>>think of a usercontrol as a class/object. it has a public interface and
>>a non-public interface. that dropdown list is not accesible publicly.
>>create a read/write property of type dropdownlist as shown below (or
>>something to that effect)
>>
>>Public Property xxx() As DropDownList
>> Get
>> return ddlView
>> End Get
>> Set(ByVal Value As DropDownList)
>> ddlView = value
>> End Set
>>End Property
>>
>>then you go
>>ucMenu.xxx.Items.FindByText("AC").Selected = True
>>
>>in that way ddlView can remain protected or private and its still ok
>>
>>VB Programmer wrote:
>>[color=darkred]
>>>On a webform that uses the usercontrol, I am trying to set the value of[/color]
>>[/color]
> a
>[color=green][color=darkred]
>>>dropdownlist that is located IN the usercontrol.
>>>
>>>Ex: ucMenu.ddlView.Items.FindByText("AC").Selected = True
>>>
>>>Is there a better way to do this?
>>>
>>>Thanks!
>>>
>>>"Kairi Zikpin" <zikkai.nospam.@netscape.net> wrote in message
>>>news:3F01991A.7080409@netscape.net...
>>>
>>>
>>>>this declaration was likely done by the vs.net (in other words, this is
>>>>generated code). vs.net could be the one changing it back, so you need
>>>>to find a better way to work with this control. why is it shared? maybe
>>>>using public properties to access the protected control would be better
>>>>
>>>>VB Programmer wrote:
>>>>
>>>>
>>>>>I changed a usercontrol dim from:
>>>>> Protected WithEvents ddlView As
>>>>
>>>System.Web.UI.WebControls.DropDownList
>>>
>>>
>>>>>to:
>>>>> Public Shared ddlView As System.Web.UI.WebControls.DropDownList
>>>>>
>>>>>I saved it SEVERAL times. It was working for about a day then, as I'm
>>>>>programming today, I notice that it's changed back to the original. Any
>>>>>ideas? This happened several times and each time I fix it it works
>>>>[/color][/color]
> fine.
>[color=green][color=darkred]
>>>>>Thanks in advace.
>>>>>
>>>>>
>>>>
>>>[/color][/color]
>
>[/color] | | | | re: Help: User control dim changes RIGHT UNDER MY NOSE!
I'm not the original poster, but I'm having the same problem. If I don't
make the property shared, I get the error "Reference to a non-shared member
requires an object reference" when trying to access the property from the
parent page.
Chris
"Kairi Zikpin" <zikkai.nospam.@netscape.net> wrote in message
news:3F0393E3.2020000@netscape.net...[color=blue]
> if the property is shared, the other item has to be shared. why is the
> property shared? i dont get that part.
>
> VB Programmer wrote:[color=green]
> > Thanks. I tried this:
> >
> > Public Shared Property ddlMyView() As DropDownList
> > Get
> > Return ddlView
> > End Get
> > Set(ByVal Value As DropDownList)
> > ddlView = Value
> > End Set
> > End Property
> >
> > But, I get a squiggly under the ddlView and it says 'Cannot refer to an
> > instance member of a class from within a shared method or a shared[/color][/color]
member[color=blue][color=green]
> > initialize without an explicit instance of the class'.
> >
> > Any more ideas? Thanks!
> >
> > "Kairi Zikpin" <zikkai.nospam.@netscape.net> wrote in message
> > news:3F01D8EA.8060509@netscape.net...
> >[color=darkred]
> >>think of a usercontrol as a class/object. it has a public interface and
> >>a non-public interface. that dropdown list is not accesible publicly.
> >>create a read/write property of type dropdownlist as shown below (or
> >>something to that effect)
> >>
> >>Public Property xxx() As DropDownList
> >> Get
> >> return ddlView
> >> End Get
> >> Set(ByVal Value As DropDownList)
> >> ddlView = value
> >> End Set
> >>End Property
> >>
> >>then you go
> >>ucMenu.xxx.Items.FindByText("AC").Selected = True
> >>
> >>in that way ddlView can remain protected or private and its still ok
> >>
> >>VB Programmer wrote:
> >>
> >>>On a webform that uses the usercontrol, I am trying to set the value of
> >>[/color]
> > a
> >[color=darkred]
> >>>dropdownlist that is located IN the usercontrol.
> >>>
> >>>Ex: ucMenu.ddlView.Items.FindByText("AC").Selected = True
> >>>
> >>>Is there a better way to do this?
> >>>
> >>>Thanks!
> >>>
> >>>"Kairi Zikpin" <zikkai.nospam.@netscape.net> wrote in message
> >>>news:3F01991A.7080409@netscape.net...
> >>>
> >>>
> >>>>this declaration was likely done by the vs.net (in other words, this[/color][/color][/color]
is[color=blue][color=green][color=darkred]
> >>>>generated code). vs.net could be the one changing it back, so you need
> >>>>to find a better way to work with this control. why is it shared?[/color][/color][/color]
maybe[color=blue][color=green][color=darkred]
> >>>>using public properties to access the protected control would be[/color][/color][/color]
better[color=blue][color=green][color=darkred]
> >>>>
> >>>>VB Programmer wrote:
> >>>>
> >>>>
> >>>>>I changed a usercontrol dim from:
> >>>>> Protected WithEvents ddlView As
> >>>>
> >>>System.Web.UI.WebControls.DropDownList
> >>>
> >>>
> >>>>>to:
> >>>>> Public Shared ddlView As System.Web.UI.WebControls.DropDownList
> >>>>>
> >>>>>I saved it SEVERAL times. It was working for about a day then, as I'm
> >>>>>programming today, I notice that it's changed back to the original.[/color][/color][/color]
Any[color=blue][color=green][color=darkred]
> >>>>>ideas? This happened several times and each time I fix it it works
> >>>>[/color]
> > fine.
> >[color=darkred]
> >>>>>Thanks in advace.
> >>>>>
> >>>>>
> >>>>
> >>>[/color]
> >
> >[/color]
>[/color] | | | | re: Help: User control dim changes RIGHT UNDER MY NOSE!
I'm not the original poster, but I'm having the same problem. If I don't
make the property shared, I get the error "Reference to a non-shared member
requires an object reference" when trying to access the property from the
parent page.
Chris
"Kairi Zikpin" <zikkai.nospam.@netscape.net> wrote in message
news:3F0393E3.2020000@netscape.net...[color=blue]
> if the property is shared, the other item has to be shared. why is the
> property shared? i dont get that part.
>
> VB Programmer wrote:[color=green]
> > Thanks. I tried this:
> >
> > Public Shared Property ddlMyView() As DropDownList
> > Get
> > Return ddlView
> > End Get
> > Set(ByVal Value As DropDownList)
> > ddlView = Value
> > End Set
> > End Property
> >
> > But, I get a squiggly under the ddlView and it says 'Cannot refer to an
> > instance member of a class from within a shared method or a shared[/color][/color]
member[color=blue][color=green]
> > initialize without an explicit instance of the class'.
> >
> > Any more ideas? Thanks!
> >
> > "Kairi Zikpin" <zikkai.nospam.@netscape.net> wrote in message
> > news:3F01D8EA.8060509@netscape.net...
> >[color=darkred]
> >>think of a usercontrol as a class/object. it has a public interface and
> >>a non-public interface. that dropdown list is not accesible publicly.
> >>create a read/write property of type dropdownlist as shown below (or
> >>something to that effect)
> >>
> >>Public Property xxx() As DropDownList
> >> Get
> >> return ddlView
> >> End Get
> >> Set(ByVal Value As DropDownList)
> >> ddlView = value
> >> End Set
> >>End Property
> >>
> >>then you go
> >>ucMenu.xxx.Items.FindByText("AC").Selected = True
> >>
> >>in that way ddlView can remain protected or private and its still ok
> >>
> >>VB Programmer wrote:
> >>
> >>>On a webform that uses the usercontrol, I am trying to set the value of
> >>[/color]
> > a
> >[color=darkred]
> >>>dropdownlist that is located IN the usercontrol.
> >>>
> >>>Ex: ucMenu.ddlView.Items.FindByText("AC").Selected = True
> >>>
> >>>Is there a better way to do this?
> >>>
> >>>Thanks!
> >>>
> >>>"Kairi Zikpin" <zikkai.nospam.@netscape.net> wrote in message
> >>>news:3F01991A.7080409@netscape.net...
> >>>
> >>>
> >>>>this declaration was likely done by the vs.net (in other words, this[/color][/color][/color]
is[color=blue][color=green][color=darkred]
> >>>>generated code). vs.net could be the one changing it back, so you need
> >>>>to find a better way to work with this control. why is it shared?[/color][/color][/color]
maybe[color=blue][color=green][color=darkred]
> >>>>using public properties to access the protected control would be[/color][/color][/color]
better[color=blue][color=green][color=darkred]
> >>>>
> >>>>VB Programmer wrote:
> >>>>
> >>>>
> >>>>>I changed a usercontrol dim from:
> >>>>> Protected WithEvents ddlView As
> >>>>
> >>>System.Web.UI.WebControls.DropDownList
> >>>
> >>>
> >>>>>to:
> >>>>> Public Shared ddlView As System.Web.UI.WebControls.DropDownList
> >>>>>
> >>>>>I saved it SEVERAL times. It was working for about a day then, as I'm
> >>>>>programming today, I notice that it's changed back to the original.[/color][/color][/color]
Any[color=blue][color=green][color=darkred]
> >>>>>ideas? This happened several times and each time I fix it it works
> >>>>[/color]
> > fine.
> >[color=darkred]
> >>>>>Thanks in advace.
> >>>>>
> >>>>>
> >>>>
> >>>[/color]
> >
> >[/color]
>[/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,419 network members.
|