asp.net - Dynamically switch between a textarea and a textbox in an asp:BoundField depending on the content length -


how can dynamically switch between text-box , text-area in asp:boundfield of gridview when displaying text editing depending on length of text content.

we can css style,

aspx page:

<style type="text/css">   #input     {         -moz-appearance: textfield;         -webkit-appearance: textfield;         background-color: white;         background-color: -moz-field;         border: 1px solid darkgray;         font: -moz-field;         font: -webkit-small-control;         width: 250px;     } </style> <body>    <div>     <asp:gridview id="gv" autogeneratecolumns="false" runat="server">          <columns>             <asp:templatefield headertext="text">                 <itemtemplate>                     <div id="input" contenteditable></div>                 </itemtemplate>             </asp:templatefield>         </columns>     </asp:gridview> </div> </body> 

aspx.cs page :

protected void page_load(object sender, eventargs e)     {         if (!ispostback)         {             bindgrid();         }     }      public void bindgrid()     {         list<string> lst = new list<string>();         lst.add("name1");         lst.add("name2");         gv.datasource = lst;         gv.databind();     } 

otherwise onkeypress event can check lenght of textbox string , if length exceeds 1 line, can change css. hope helpful you.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -