Composite control and resizing

J

J.Marsch

I'm a little new to Web Forms, and building web form controls:

I am trying to build a simple composite web form control. It contains a
Label, with a TextBox
At design time, if the user attempts to resize the control, I want for the
Textbox to resize along with it, so that its width matches that of the
container, and if you change the height of the container, the height of the
Textbox is adjusted -- basically, the text box should take up the entire
container except for the space used by the Label.

No matter how hard I fight it, I cannot seem to get this resize behavior to
work right.
What seems to be throwing me off is that it appears to be possible to have
an empty height. How can I figure out how to set the height of the
contained control if the label shows a height of 0? It's height obviously
isn't zero, because I can see it when it renders. I think that there is
either a bug, or something basic that I don't follow.



I didn't think it should be too difficult. Here's basically what I've got:

(leaving out some additional complexity)

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
this.EnsureChildControls();
this.EditControl.Width = this.Width;
this.EditControl.Height = new Unit(this.Height.Value -
this.FieldLabel.Height.Value);
base.Render(writer);
}

protected override void CreateChildControls()
{
this.FieldLabel = new Label();
this.Controls.Add(this.FieldLabel);
this.EditControl = new TextBox();
this.Controls.Add(this.EditControl);
 
T

Tian Min Huang

Hi,

I am checking this issue and will update you with my information.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

J.Marsch

Thanks Tian:

I noticed that I left out one item in code that I posted to you. In the
CreateChildControls method, I insert a literal <br> after the label, so that
the label and the edit control appear on separate lines:

protected override void CreateChildControls()
{
this.FieldLabel = new Label();
this.Controls.Add(this.FieldLabel);

Literal lineBreak = new Literal();
lineBreak.Text = "<br>";
this.Controls.Add(lineBreak);

this.EditControl = new TextBox();
this.Controls.Add(this.EditControl);
}
 
G

Genich

I run your code and it work fine in resizing the child controls on the
designer the way you want it them to.
If that don't help you, try this:
this.EditControl.Width = Unit.Percentage(100);
//this.Width;
this.EditControl.Height = Unit.Percentage(100);
 
J

Jim Cheshire [MSFT]

Jeremy,

In order for me to reproduce the problem you are encountering, can you
provide me with a scaled-down reproduction of what you are doing? You can
e-mail it to me at the e-mail address on this post. Just leave off the
"online".

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
 
J

Jim Cheshire [MSFT]

Jeremy,

I haven't heard from you, so I'll assume you got it fixed up. If you still
need my help, post back!

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
X-Tomcat-ID: 657658793
References: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Jim Cheshire [MSFT])
Organization: Microsoft
Date: Mon, 13 Oct 2003 18:02:17 GMT
Subject: Re: Composite control and resizing
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Message-ID: <bnW#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Lines: 58
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7750
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Jeremy,

In order for me to reproduce the problem you are encountering, can you
provide me with a scaled-down reproduction of what you are doing? You can
e-mail it to me at the e-mail address on this post. Just leave off the
"online".

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
Reply-To: "J.Marsch" <[email protected]>
From: "J.Marsch" <[email protected]>
References: <[email protected]>
Subject: Re: Composite control and resizing
Date: Thu, 9 Oct 2003 10:21:54 -0500
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
NNTP-Posting-Host: 206.52.52.37
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7669
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols

Thanks Tian:

I noticed that I left out one item in code that I posted to you. In the
CreateChildControls method, I insert a literal <br> after the label, so that
the label and the edit control appear on separate lines:

protected override void CreateChildControls()
{
this.FieldLabel = new Label();
this.Controls.Add(this.FieldLabel);

Literal lineBreak = new Literal();
lineBreak.Text = "<br>";
this.Controls.Add(lineBreak);

this.EditControl = new TextBox();
this.Controls.Add(this.EditControl);
}
 
J

J.Marsch

Jim:

Sorry that you haven't heard from me, I've been on a little bit of fire-duty
lately.

I think that I have the problem worked out. I had to set the initial size
of the label (it evaluated as empty before). I haven't tried changing the
width settings to 100% rather than trying to match the current width of the
container. I expect that will probably help as well.

Thanks for your help.

Jim Cheshire said:
Jeremy,

I haven't heard from you, so I'll assume you got it fixed up. If you still
need my help, post back!

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
X-Tomcat-ID: 657658793
References: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Jim Cheshire [MSFT])
Organization: Microsoft
Date: Mon, 13 Oct 2003 18:02:17 GMT
Subject: Re: Composite control and resizing
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Message-ID: <bnW#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Lines: 58
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7750
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Jeremy,

In order for me to reproduce the problem you are encountering, can you
provide me with a scaled-down reproduction of what you are doing? You can
e-mail it to me at the e-mail address on this post. Just leave off the
"online".

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
Reply-To: "J.Marsch" <[email protected]>
From: "J.Marsch" <[email protected]>
References: <[email protected]>
Subject: Re: Composite control and resizing
Date: Thu, 9 Oct 2003 10:21:54 -0500
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
NNTP-Posting-Host: 206.52.52.37
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7669
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols

Thanks Tian:

I noticed that I left out one item in code that I posted to you. In the
CreateChildControls method, I insert a literal <br> after the label, so that
the label and the edit control appear on separate lines:

protected override void CreateChildControls()
{
this.FieldLabel = new Label();
this.Controls.Add(this.FieldLabel);

Literal lineBreak = new Literal();
lineBreak.Text = "<br>";
this.Controls.Add(lineBreak);

this.EditControl = new TextBox();
this.Controls.Add(this.EditControl);
}

Hi,

I am checking this issue and will update you with my information.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

J.Marsch

Jim:

Sorry that you haven't heard from me, I've been on a little bit of fire-duty
lately.

I think that I have the problem worked out. I had to set the initial size
of the label (it evaluated as empty before). I haven't tried changing the
width settings to 100% rather than trying to match the current width of the
container. I expect that will probably help as well.

Thanks for your help.

Jim Cheshire said:
Jeremy,

I haven't heard from you, so I'll assume you got it fixed up. If you still
need my help, post back!

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
X-Tomcat-ID: 657658793
References: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Jim Cheshire [MSFT])
Organization: Microsoft
Date: Mon, 13 Oct 2003 18:02:17 GMT
Subject: Re: Composite control and resizing
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Message-ID: <bnW#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Lines: 58
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7750
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Jeremy,

In order for me to reproduce the problem you are encountering, can you
provide me with a scaled-down reproduction of what you are doing? You can
e-mail it to me at the e-mail address on this post. Just leave off the
"online".

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
Reply-To: "J.Marsch" <[email protected]>
From: "J.Marsch" <[email protected]>
References: <[email protected]>
Subject: Re: Composite control and resizing
Date: Thu, 9 Oct 2003 10:21:54 -0500
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
NNTP-Posting-Host: 206.52.52.37
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7669
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols

Thanks Tian:

I noticed that I left out one item in code that I posted to you. In the
CreateChildControls method, I insert a literal <br> after the label, so that
the label and the edit control appear on separate lines:

protected override void CreateChildControls()
{
this.FieldLabel = new Label();
this.Controls.Add(this.FieldLabel);

Literal lineBreak = new Literal();
lineBreak.Text = "<br>";
this.Controls.Add(lineBreak);

this.EditControl = new TextBox();
this.Controls.Add(this.EditControl);
}

Hi,

I am checking this issue and will update you with my information.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

J.Marsch

Jim:

Sorry that you haven't heard from me, I've been on a little bit of fire-duty
lately.

I think that I have the problem worked out. I had to set the initial size
of the label (it evaluated as empty before). I haven't tried changing the
width settings to 100% rather than trying to match the current width of the
container. I expect that will probably help as well.

Thanks for your help.

Jim Cheshire said:
Jeremy,

I haven't heard from you, so I'll assume you got it fixed up. If you still
need my help, post back!

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
X-Tomcat-ID: 657658793
References: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Jim Cheshire [MSFT])
Organization: Microsoft
Date: Mon, 13 Oct 2003 18:02:17 GMT
Subject: Re: Composite control and resizing
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Message-ID: <bnW#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Lines: 58
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7750
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Jeremy,

In order for me to reproduce the problem you are encountering, can you
provide me with a scaled-down reproduction of what you are doing? You can
e-mail it to me at the e-mail address on this post. Just leave off the
"online".

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
Reply-To: "J.Marsch" <[email protected]>
From: "J.Marsch" <[email protected]>
References: <[email protected]>
Subject: Re: Composite control and resizing
Date: Thu, 9 Oct 2003 10:21:54 -0500
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
NNTP-Posting-Host: 206.52.52.37
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7669
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols

Thanks Tian:

I noticed that I left out one item in code that I posted to you. In the
CreateChildControls method, I insert a literal <br> after the label, so that
the label and the edit control appear on separate lines:

protected override void CreateChildControls()
{
this.FieldLabel = new Label();
this.Controls.Add(this.FieldLabel);

Literal lineBreak = new Literal();
lineBreak.Text = "<br>";
this.Controls.Add(lineBreak);

this.EditControl = new TextBox();
this.Controls.Add(this.EditControl);
}

Hi,

I am checking this issue and will update you with my information.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jim Cheshire [MSFT]

Jeremy,

No problem. I know how it goes. If you need more help, just post back.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
Reply-To: "J.Marsch" <[email protected]>
From: "J.Marsch" <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
Subject: Re: Composite control and resizing
Date: Thu, 16 Oct 2003 17:15:08 -0500
Lines: 129
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
NNTP-Posting-Host: 206.52.52.37
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7802
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols

Jim:

Sorry that you haven't heard from me, I've been on a little bit of fire-duty
lately.

I think that I have the problem worked out. I had to set the initial size
of the label (it evaluated as empty before). I haven't tried changing the
width settings to 100% rather than trying to match the current width of the
container. I expect that will probably help as well.

Thanks for your help.

Jim Cheshire said:
Jeremy,

I haven't heard from you, so I'll assume you got it fixed up. If you still
need my help, post back!

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
X-Tomcat-ID: 657658793
References: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Jim Cheshire [MSFT])
Organization: Microsoft
Date: Mon, 13 Oct 2003 18:02:17 GMT
Subject: Re: Composite control and resizing
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Message-ID: <bnW#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
Lines: 58
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.buildingcontrols:7750
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Jeremy,

In order for me to reproduce the problem you are encountering, can you
provide me with a scaled-down reproduction of what you are doing? You can
e-mail it to me at the e-mail address on this post. Just leave off the
"online".

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
Reply-To: "J.Marsch" <[email protected]>
From: "J.Marsch" <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: Re: Composite control and resizing
Date: Thu, 9 Oct 2003 10:21:54 -0500
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
NNTP-Posting-Host: 206.52.52.37
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:7669
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols

Thanks Tian:

I noticed that I left out one item in code that I posted to you. In the
CreateChildControls method, I insert a literal <br> after the label, so
that
the label and the edit control appear on separate lines:

protected override void CreateChildControls()
{
this.FieldLabel = new Label();
this.Controls.Add(this.FieldLabel);

Literal lineBreak = new Literal();
lineBreak.Text = "<br>";
this.Controls.Add(lineBreak);

this.EditControl = new TextBox();
this.Controls.Add(this.EditControl);
}

Hi,

I am checking this issue and will update you with my information.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top