Getting an asp.net TextBox to fill a screen and adjust heightdynamically

T

Terry

I am trying to figure out if there is a way to get a regular asp.net
TextBox to fill the screen, both height and width. When I drop a
TextBox onto a blank asp.net page and set the height="100%",
width="100", and the TextMode="MultiLine", the TextBox will fill the
width of the page, and will adjust the width dynamically as the page
changes size, but the height of the textbox is not full screen as I
would like. It remains at 2 lines high.

Is there a way to get the height of a textbox to fill the screen, and
adjust its size automatically when the screen size changes? Thanks.
 
S

Scott M.

Textbox height may only be adjusted on a row of input basis by setting the
Textmode property to Multi-line and then the Rows property to the desired
row amount. You cannot set a textbox's height in pixels or percent, as you
can do with other controls.
 
T

Terry

So does that mean it is not possible to set the TextBox height so that
it will be full screen, and automatically adjust when the page size is
changed?

Ultimately what I'm trying to do is create a page very similar to an e-
mail inbox page, with a grid on the top half of the screen, a splitter
bar, and a TextBox at the bottom that always fills the bottom half of
the page, even when the splitter bar is adjusted. I was hoping I
could do this with a TextBox on the bottom. Any suggestions?
 
B

bruce barker

trival:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FullTextBox.aspx.cs"
Inherits="FullTextBox" %>
<html>
<body style="margin:2px;border:0px;padding:0px;"
onresize="doResize();"
onload="doResize();"<script>
function doResize(){
var txt1 = document.getElementById('<%=txt1.ClientID %>');
txt1.style.height=(document.body.clientHeight-6)+'px';
}
</script>
<form id="form1" runat="server">
<asp:textbox
id="txt1"
style="width:100%;margin:0px;border:1px black solid;padding:0px;"
runat="server"
TextMode="MultiLine"
/>
</form>
</body>
</html>


-- bruce (sqlwork.com)
 
T

Terry

Thanks Bruce! That that worked exactly as I had hoped.

I did find that the "onresize" event in the body element is not valid
for XHTML Transitional markup. I took out the DOCTYPE reference to
test your code, and it worked. I'll probably have to find a work-
around for the onresize event if I want my web page to enforce XHTML
Transitional.

Thanks again.
 
B

bruce barker

xhtml has no replacement (it just depicated, not removed), but its a valid
event for html 4.0/ 5.0/ xhtml2 (undepicated if htmlelement).


-- bruce (sqlwork.com)
 
Joined
Nov 16, 2011
Messages
1
Reaction score
0
TextBox b=new TextBox ();
b.TextMode=TextBoxMode.MultiLine; // for Textmode
b.Width=200; //for Width
b.Height = 100; //for Height



 

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,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top