c# - How can I make a Sharepoint textbox (input, type=text) dynamically Multiline? -
i want textbox on web part grow vertically on demand. is, 1 line unless user enters text line, @ point word wraps , grows vertically accommodate verbosity of user.
i creating controls/elements dynamically, , create element so:
boxpaymentexplanation = new textbox() { cssclass = "dplatypus-webform-field-input" }; boxpaymentexplanation.width = 660; boxpaymentexplanation.style.add("display", "inline-block");
i tried adding line, in hopes of achieving functionality:
boxpaymentexplanation.style.add("textmode", "multiline");
...but makes no apparent change textbox's behavior - can enter text "until bovines come barn" keeps adding characters end of textbox on single row. never wraps, never grows.
update
this jquery works (derived link christopher jennings provided):
$(document).on("keyup", "[id$=explainpaymenttextbox]", function (e) { while ($(this).outerheight() < this.scrollheight + parsefloat($(this).css("bordertopwidth")) + parsefloat($(this).css("borderbottomwidth"))) { $(this).height($(this).height() + 1); }; });
...along c#:
boxpaymentexplanation = new textbox() { cssclass = "dplatypus-webform-field-input", id = "explainpaymenttextbox" }; boxpaymentexplanation.width = 660; boxpaymentexplanation.style.add("display", "inline-block"); boxpaymentexplanation.textmode = textboxmode.multiline;
update 2
unfortunately, although descent-into-the-mælström-esque jquery above works dynamically growing textbox, doesn't work if user removes text; shrink when happens...
you're on right track. need set textmode property multiline. however, approach took add html tag attribute rather set .net property. replace boxpaymentexplanation.style.add("textmode", "multiline");
boxpaymentexplanation.textmode = textboxmode.multiline;
Comments
Post a Comment