Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > DefaultValue for Public Property of ASP.NET 2.0 UserControl not appearing in Properties Window

Reply
Thread Tools

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

 
 
Shadow Lynx
Guest
Posts: n/a
 
      02-28-2006
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>

 
Reply With Quote
 
 
 
 
DWS
Guest
Posts: n/a
 
      02-28-2006
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>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSE 4 11-15-2006 02:40 AM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSD 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments
 



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