I'm using a textarea control to allow the user to input text and then place that text into the body of an e-mail. In the code behind, what is the syntax for referencing the users input? I thought I could just use message.Body = test123.Text;
but this is not recognized.
HTML:
<textarea id="TextArea1" cols="20" rows="2" ></textarea>
CodeBehind:
foreach (string recipient in recipients) { var message = new System.Net.Mail.MailMessage("[email protected]", recipient); message.Subject = "Hello World!"; message.Body = test123.Text; client.Send(message); }
The <textarea> tag defines a multi-line text input control. The <textarea> element is often used in a form, to collect user inputs like comments or reviews. A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).
The <textarea> element also accepts several attributes common to form <input> s, such as autocomplete , autofocus , disabled , placeholder , readonly , and required .
From the MDN documentation: " <textarea> does not support the value attribute".
You are not using a .NET control for your text area. Either add runat="server"
to the HTML TextArea control or use a .NET control:
Try this:
<asp:TextBox id="TextArea1" TextMode="multiline" Columns="50" Rows="5" runat="server" />
Then reference it in your codebehind:
message.Body = TextArea1.Text;
You need to use runat="server"
like this:
<textarea id="TextArea1" cols="20" rows="2" runat="server"></textarea>
You can use the runat=server attribute with any standard HTML element, and later use it from codebehind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With