U
U
usmdamir2017-05-15 15:30:06
ASP.NET
usmdamir, 2017-05-15 15:30:06

Validating form fields in ASP.NET?

good afternoon.
there is a form like this:

<h3>Обратная связь</h3>
<table>
<tr style="display:none;">
<td></td>
<td><asp:TextBox size="30" runat="server" ID="SubjectTextBox" Width="132px" style="padding: 2px; margin: 0; border: 1px solid gray" /></td>
</tr>
<tr>
<td>Тема:</td>
<td valign="top"><asp:TextBox size="30" runat="server" ID="TopicTextBox" Width="132px" style="padding: 2px; margin: 0; border: 1px solid gray" /></td>
</tr>
<tr>
<td>Е-mail:</td>
<td valign="top" ><asp:TextBox size="30" runat="server" ID="ЕmailTextBox" Width="132px" style="padding: 2px; margin: 0; border: 1px solid gray"/></td>
</tr>
<tr>
<td>Текст сообщения:</td>
<td valign="top" >
<asp:TextBox Rows="10" runat="server" ID="MessageTextBox" Columns="50" TextMode="MultiLine" Width="132px" style="padding: 2px; margin: 0; border: 1px solid gray"/>
</td>
</tr>
<tr>
<td valign="top"></td>
<td valign="top"><asp:Button runat="server" ID="SendButton" Text="Отправить" OnClick="SendButton_Click" /></td>
</tr>
</table>

how to add validation of form fields for filling? And then too often empty letters come to the post office.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
usmdamir, 2017-05-15
@usmdamir

figured it out myself.
read the documentation

<asp:TextBox runat="server" Width="200px" ID="Name" />
<asp:RequiredFieldValidator runat="server" ID="ValidateName" ControlToValidate="Name" 
         ErrorMessage="Имя пустое" Display="dynamic">*
</asp:RequiredFieldValidator>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question