DefaultValue for Public Property of ASP.NET 2.0 UserControl not appearing in Properties Window

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

  1. #1

    Default DefaultValue for Public Property of ASP.NET 2.0 UserControl not appearing in Properties Window

    First, I'm using Visual Web Developer 2005 Express Edition, which I
    hope is exactly the same as Visual Studio 2005 minus a bunch of useful
    features.
    While the property itself (Amount) appears as it should in the
    Properties Window, the DefaultValue is never set (it is always blank).
    If I enter the default value, it is not bold, indicating that it is at
    least aware of what the DefaultValue should be. The strangest thing is
    that, in Source view, the DefaultValue DOES appear in the Properties
    Window! What's the deal!? Here's a very simple example:

    ASCX:
    <%@ Control Language="VB" AutoEventWireup="false"
    CodeFile="TestControl.ascx.vb" Inherits="TestControl" %>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

    ASCX.VB:
    Imports System.ComponentModel
    Partial Class TestControl
    Inherits System.Web.UI.UserControl
    Private _Amount As Integer = 100
    <DefaultValue(100)> _
    Public Property Amount() As Integer
    Get
    Return _Amount
    End Get
    Set(ByVal value As Integer)
    _Amount = value
    End Set
    End Property
    End Class

    ASPX:
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb"
    Inherits="Test" %>
    <%@ Register Src="TestControl.ascx" TagName="TestControl"
    TagPrefix="uc1" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Test</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <uc1:TestControl ID="TestControl1" runat="server" />
    </div>
    </form>
    </body>
    </html>

    ASPX.VB:
    Partial Class Test
    Inherits System.Web.UI.Page
    End Class

    I'd also like to know if there's any way to add resizing handles (along
    with the associated Width and Height properties) to a UserControl.
    That's the ultimate goal of this exercise - to make a UserControl that
    is sizable via handles in the designer as well as linked Width and
    Height properties. I tried using a panel to surround all of the
    controls in my UserControl and linking Width and Height to its Width
    and Height, but to no avail (at least in the designer there was no
    change.)

    <ASP:RANT>
    Last question which is completely unimportant: Does it drive anyone
    else nuts when you're editng the Attributes <...> of a
    Property/Class/etc. and it horizontally shifts the first line of the
    definition line into a screwy, non-tabbed position? This happened to
    me in VS 2003 as well as this VWD 2005.

    <Description("Whatever")> _
    Public Property Thingy() As Integer
    ' The line above shifts left 3 characters
    ' when changing any Attribute. Annoying!
    ...
    End Property
    </ASP:RANT>

    Shadow Lynx Guest

  2. Similar Questions and Discussions

    1. properties not showing in properties window at design time
      I created a usercontrol using vb but the properties will not show in the properties pane however the properties show up in the intellisence list....
    2. #25441 [Opn->Csd]: public properties of parent class not accessible
      ID: 25441 Updated by: sniper@php.net Reported By: tater at potatoe dot com -Status: Open +Status: ...
    3. User Control Public Property Problem
      I have built a user control that displays the header on a web forms. It has a public property ("Msg") that I can set to display error messages from...
    4. #25441 [NEW]: public properties of parent class not accessible
      From: tater at potatoe dot com Operating system: OS X 10.2 PHP version: 5CVS-2003-09-08 (dev) PHP Bug Type: Zend Engine 2...
    5. Problem: public array loses elements (in usercontrol)
      I have a public array (in a usercontrol) defined as: Public arrWebServers(0) As WebServers ' FYI: Public Structure WebServers Friend...
  3. #2

    Default RE: DefaultValue for Public Property of ASP.NET 2.0 UserControl not ap

    Shadow,
    First thanks for downloading the express edition. Hopefully you've got all
    of em. I lucked out and got a standard edition by attending a launch event.
    Don't forget to grab your free graphics, I'm already using a bunch on my dev
    web site.

    For your qeustion Its by design defaults are not included in the page
    markup. Don't worry ASP.Net will compile the default value into the dll for
    the page. If you change your default do you want to contact every user that
    downloaded your control they have to change their pages? No you send them
    the updated dll. What if the default is localized?

    Good Luck
    DWS

    "Shadow Lynx" wrote:
    > First, I'm using Visual Web Developer 2005 Express Edition, which I
    > hope is exactly the same as Visual Studio 2005 minus a bunch of useful
    > features.
    > While the property itself (Amount) appears as it should in the
    > Properties Window, the DefaultValue is never set (it is always blank).
    > If I enter the default value, it is not bold, indicating that it is at
    > least aware of what the DefaultValue should be. The strangest thing is
    > that, in Source view, the DefaultValue DOES appear in the Properties
    > Window! What's the deal!? Here's a very simple example:
    >
    > ASCX:
    > <%@ Control Language="VB" AutoEventWireup="false"
    > CodeFile="TestControl.ascx.vb" Inherits="TestControl" %>
    > <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    >
    > ASCX.VB:
    > Imports System.ComponentModel
    > Partial Class TestControl
    > Inherits System.Web.UI.UserControl
    > Private _Amount As Integer = 100
    > <DefaultValue(100)> _
    > Public Property Amount() As Integer
    > Get
    > Return _Amount
    > End Get
    > Set(ByVal value As Integer)
    > _Amount = value
    > End Set
    > End Property
    > End Class
    >
    > ASPX:
    > <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb"
    > Inherits="Test" %>
    > <%@ Register Src="TestControl.ascx" TagName="TestControl"
    > TagPrefix="uc1" %>
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="http://www.w3.org/1999/xhtml" >
    > <head runat="server">
    > <title>Test</title>
    > </head>
    > <body>
    > <form id="form1" runat="server">
    > <div>
    > <uc1:TestControl ID="TestControl1" runat="server" />
    > </div>
    > </form>
    > </body>
    > </html>
    >
    > ASPX.VB:
    > Partial Class Test
    > Inherits System.Web.UI.Page
    > End Class
    >
    > I'd also like to know if there's any way to add resizing handles (along
    > with the associated Width and Height properties) to a UserControl.
    > That's the ultimate goal of this exercise - to make a UserControl that
    > is sizable via handles in the designer as well as linked Width and
    > Height properties. I tried using a panel to surround all of the
    > controls in my UserControl and linking Width and Height to its Width
    > and Height, but to no avail (at least in the designer there was no
    > change.)
    >
    > <ASP:RANT>
    > Last question which is completely unimportant: Does it drive anyone
    > else nuts when you're editng the Attributes <...> of a
    > Property/Class/etc. and it horizontally shifts the first line of the
    > definition line into a screwy, non-tabbed position? This happened to
    > me in VS 2003 as well as this VWD 2005.
    >
    > <Description("Whatever")> _
    > Public Property Thingy() As Integer
    > ' The line above shifts left 3 characters
    > ' when changing any Attribute. Annoying!
    > ...
    > End Property
    > </ASP:RANT>
    >
    >
    DWS 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