Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set textbox row property using dynamically

Status
Not open for further replies.

Tomorrow

Programmer
Jan 9, 2003
12
AU
Hi,

I am using an asp:textbox and I want to set the value of the "rows" property
dynamically depending on the amount of data in the field.

<asp:textbox ID="txtSummary" runat="server" wrap="true" width="650px" rows=15
readonly="true" textmode="MultiLine" BorderStyle="None"
BorderWidth="0" style="overflow:hidden; font-family:Verdana; font-size:11px; color: #454f58;"
Text='<%# Bind("Summary") %>'></asp:textbox>

Any help would be appreciated

thanks
 
do you mean dynamically when the page loads, or dynamically as the user is typing?
if it's the first you can just bind it to a variable
Code:
//code behind
protected int dyanamicRows = 15;

//markup
<asp:textbox ID="txtSummary" rows='<%=dynamicRows%>'

--or
//during page load event
txtSummary.Rows = dyanamicRows;
if it's the later you need to use js on the client to change the height of the textarea.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Thanks for that, I needed to do the following as I am using VB

'code-behind
'set the variable dynamic as a type public (not private)
public dynamicrows as integer

'on page_load
dynamicrows = 15

'markuprows
rows = '<%# dynamicrows %>'

Your answer helped point me in the right direction
Thanks again


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top