Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Aspx and hidden WebControl properties

Reply
Thread Tools

Aspx and hidden WebControl properties

 
 
rrutkowski@gmail.com
Guest
Posts: n/a
 
      09-25-2008
Hi!

I have the following situation

public class Class1 : WebControl
{
public Class1()
: base(HtmlTextWriterTag.Div)
{
}

public new virtual int? Width
{
get { return this.ViewState["Width"] as int?; }
set { this.ViewState["Width"] = value; }
}

public new virtual int? Height
{
get { return this.ViewState["Height"] as int?; }
set { this.ViewState["Height"] = value; }
}

protected override void RenderContents(HtmlTextWriter writer)
{
writer.Write("{0}x{1}", this.Width, this.Height);
}
}

The Width and Height properties of the WebControl are hidden and their
type is changed to a nullable int. Then I have a derived class:

public class Class2:Class1
{
public override int? Width
{
get { return base.Width; }
set { base.Width = value; }
}
}

Now, in the aspx I have
<test:Class2 Width="500" Height="100" runat="server" />

I expect to get as a result: <div>500x100</div>
But I keep getting: <div Height="100">500x<div> (the Height property
is never assigned a value)

Why does aspx keep ignoring a previously hidden property if it is not
overridden?

I'm using the Visual Studio 2008 SP1 and .NET Framework 3.5 SP1. IIS 7
on a Windows Server 2008.

--
Regards
Rudy
 
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
Re: passing hidden fields from aspx to asp and back to aspx Nirosh ASP .Net 0 04-28-2009 05:44 AM
Trapping an Exception ocurring in a Webcontrol at the Page or parent WebControl level. ASP .Net 2 01-31-2005 06:34 PM
WebControl inside of WebControl and attaching events Kasabaarde Sumta ASP .Net Building Controls 0 12-13-2004 09:51 PM
Persist properties to aspx file on webcontrol creation Raymond Tellenbach via .NET 247 ASP .Net Web Controls 0 08-04-2004 03:58 PM
Can a webcontrol (webcontrol.dll) have a configuration file? Luis Ramírez. ASP .Net Building Controls 2 07-06-2004 04:35 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