By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Help: User control dim changes RIGHT UNDER MY NOSE!

P: n/a
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.
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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 fine.

Thanks in advace.


Nov 17 '05 #2

P: n/a
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:
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:3F**************@netscape.net...
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

a
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:3F**************@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
fine.
Thanks in advace.
>
>



Nov 17 '05 #3

P: n/a
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:3F**************@netscape.net...
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:
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:3F**************@netscape.net...
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

a
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:3F**************@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
>

fine.
>>Thanks in advace.
>>
>>
>


Nov 17 '05 #4

P: n/a
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:3F**************@netscape.net...
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:
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:3F**************@netscape.net...
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

a
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:3F**************@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
>

fine.
>>Thanks in advace.
>>
>>
>


Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.