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

  • Thread starter Thread starter Terry
  • Start date Start date
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.
 
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.
 
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?
 
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)
 
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.
 
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)
 
Back
Top