Help: User control dim changes RIGHT UNDER MY NOSE!

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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.


    VB Programmer Guest

  2. Similar Questions and Discussions

    1. user control problem access value from user control to a page
      Thanks a lot for paying attention to my problem , i tell u the problem i have a main form in which i gave a login label that points to a...
    2. Dynamically Adding User Control with Child User Control
      I have a user control that has a child user control. If I drag this onto the page, it appears and functions normally. If I attempt to add the...
    3. Know in user control page_load if an user control event is going to be fired
      Hi all, i have built a user control that shows a map and let the user zoom in, out, usual stuff. Putting this object in a webform the user can...
    4. Page Load fired 3 times Web user control is embedded in a custom control
      Hi, I have built a custom control that build a table with 3 cells in it. The custom control is designed to add all child controls to cell#2,...
    5. nose desprogramo todo la red en mi computador
      no se como abtener ayuda y programarla
  3. #2

    Default 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:
    > 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.
    >
    >
    Kairi Zikpin Guest

  4. #3

    Default 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:
    > 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...
    >
    >>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: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
    >>>>
    > fine.
    >
    >>>>>Thanks in advace.
    >>>>>
    >>>>>
    >>>>
    >>>
    >
    >
    Kairi Zikpin Guest

  5. #4

    Default 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...
    > 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:3F01D8EA.8060509@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: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
    > >>>>
    > > fine.
    > >
    > >>>>>Thanks in advace.
    > >>>>>
    > >>>>>
    > >>>>
    > >>>
    > >
    > >
    >

    Chris Mahoney Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139