Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I added a multiline textbox to gridview in my website project in c# Asp.net. I will retrieve text from database to my textbox.

I set the width and height of texbox to 100% and put it in a div. But when I view the site in browser doesnt fill the div and it is resizeable. I also set the height and width of div to 100% in my .css file.

How can I fill the div with textbox and lock the size of textbox?
Posted
Updated 23-Sep-12 3:47am
v3
Comments
Sandeep Mewara 23-Sep-12 9:37am    
Not clear.
Pooya F.A 23-Sep-12 9:42am    
I want to stop the user from increasing the height or width of textbox.
Sergey Alexandrovich Kryukov 23-Sep-12 11:13am    
The basic problem seems to be clear, but some detail would be needed. Could you write a simple sample with just one text box to reproduce the problem. As it is only related to HTML (and probably CSS), not ASP.NET, it would be good if this is pure HTML code.
--SA

1 solution

In C#:
C#
<asp:textbox id="txtComments" runat="server" bordercolor="Gray" xmlns:asp="#unknown">
           BorderStyle="Solid" BorderWidth="1px" CausesValidation="true" Wrap="true"
           MaxLength="100"
           TextMode="MultiLine" 
           Width="350px"></asp:textbox>


in aspx.cs
C#
public int MaxLength
   {
       get { return txtComments.MaxLength; }
       set { txtComments.MaxLength = value; }
   }
   public void wordCount()
   {
       txtCount.Text = txtComments.MaxLength.ToString();
       txtComments.Attributes.Add("onKeyUp", "javascript:document.getElementById('" + txtCount.ClientID + "').setAttribute('value', (" + txtComments.MaxLength + " - parseInt(document.getElementById('" + txtComments.ClientID + "').getAttribute('value').length)));");

   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900