Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / February 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shadow Lynx - 28 Feb 2006 04:42 GMT
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 - 28 Feb 2006 16:11 GMT
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

> 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
[quoted text clipped - 75 lines]
>     End Property
> </ASP:RANT>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.