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


S

Shadow Lynx

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>
 
Ad

Advertisements

D

DWS

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top