Thursday, March 22, 2012

textarea (multi line) how to set default value ?

Hi,
I cannot figure out how to set the default value for a <textarea> control in my page:

Here is my current code for this control:

<textarea name="contMessage" cols="35" rows="5" id="contMessage" runat="server" tooltip="enter your message here" /></textarea
how do I add a default value for this multi-line text field?


<textarea name="contMessage" cols="35" rows="5" id="contMessage" runat="server" tooltip="enter your message here" />
THIS IS THE TEXT APEARING IN THE TEXTAREA
</textarea>

put the text in between the textarea tags like so...

<textarea name="contMessage" cols="35" rows="5" id="contMessage" runat="server" tooltip="enter your message here" />Place your default text here!!!</textarea


Thanks for the replies.

That does not work for me ? It just puts the text I have between the tags, next to the textarea field, not within it ?

I have found the following to accomplish what I'm after, but am a little confused still:

<asp:textbox Text="This text does show WITHIN the text box" textmode="MultiLine" columns="35" rows="5" id="contMessage" runat="server" tooltip="enter your message here" />Text here shows NEXT to the text box</asp:textbox

Is this just me ? Is there something going on in ther st of my form to have this effect?
you are confusing 2 things - textbox and htmltextarea - try this


<asp:TextBox id="Text1"
Text="This will show up in textbox"
TextMode="MultiLine"
Columns="50"
Rows="5"
runat="server"/>

In addition....
I'd like to bind some data collected from the querystring to the default content of the textbox I've tried:

<asp:textbox Text='<%# Response.Write(Request.QueryString("page")) %>' textmode="MultiLine" columns="35" rows="5" id="contMessage" runat="server" tooltip="enter your message here" /></asp:textbox>

but this produces an error:

Compiler Error Message: BC30518: Overload resolution failed because no accessible 'ToString' can be called with these arguments:
Remove the response.write.
thanks for that, but it still doesn't apear to work without the response.write :


<asp:textbox Text='<%#(Request.QueryString("page"))%>' TextMode="MultiLine" Columns="35" Rows="5" ID="contMessage" runat="server" ToolTip="enter your message here"></asp:textbox>

this does not display anything for me. the querystring does have the appropriate string, I have a basic text response.write on another part of the page that works fine, but not within the textbox.

and just to go back to the textarea option (I'm not sure of the difference yet, but I can google that), is it just me who can't get a default value in the textarea by adding text in between the tags ? I just get that text next to the text box, not within it ?

any further help appreciated.
Im not sure how to do it that way ( still lookin around) but you can do it this way..
add the text assignment to the page load...

Sub Page_Load(Source As Object, E As EventArgs)
text1.text=request.querystring("page")
End Sub

aslo here are some links i use..
http://samples.gotdotnet.com/quickstart/aspplus/doc/webcontrolsref.aspx

text is a .Net WEBcontrol
textarea is a HTMLcontrol

I also refer to this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp

most of the controls you will use are under System.Web.UI.controls on left panel

HTH

0 comments:

Post a Comment