asp.net control to expand textbox?
I'm not sure what this functionality is properly called. But I have a single-line t开发者_StackOverflow社区ext box in an asp.net gridview. When a user clicks on that textbox, I want a larger, multi-line textbox to pop-up, so they can see the entire contents and edit it. This expanded view would go away once the focus moves to another control.
Is there a control out there that allows for this? If not, how could I go about implementing one?
EDIT: I'm looking for similar function to how the TextBoxCalendar Extender works, but instead of a calendar, I'd like a multiline textbox to pop.
This blog post has an elastic textbox that uses jQuery. According to the author,
...when the TextBox gets the focus, it will expand to a specified height and width and then when it loses focus it will contract back to it’s more compact size.
You will need to look at using javascript/jquery if you want to do this without a postback (which I would recommend).
The link below goes over a good method for doing this:
- http://www.webdeveloper.com/forum/showthread.php?t=175514
Here is the function they call:
function expand(width,height)
{
document.getElementById("text_output").cols = width;
document.getElementById("text_output").rows = height;
}
There may also be a control in the .net AJAX tool kit that does this, but the javascript route would probably be simpler.
UPDATE:
If you are looking for popup functionality then I would definately go the jQuery route. Typically they will have you specify a div that you would like to have popup on a certain event. The link below gives you a number of modal popup plugins that you can look at using:
- http://choosedaily.com/1178/15-jquery-popup-modal-dialog-plugins-tutorials/
If your talking about an asp.net Textbox you can specify the number of rows like so:
<asp:TextBox id="tb6" rows="5" TextMode="multiline" runat="server" />
See this link for more info
You can just use a textbox control, and add an onclick Event handler that changes the "rows" property to something greater than 1, thus multi-line.
精彩评论