0
我在asp.net新;我嘗試添加RequiredFieldValidator到電話號碼部分,但我不能在Visual Studio 2010,因爲它沒有「id」,當我在類中添加id時,它仍然沒有顯示。Asp.net驗證與div
另外我怎樣才能在提交按鈕上添加onclick?用一個RequiredFieldValidator所示
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="odevproje._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<fieldset>
<div class="legend"><h3>iletişim</h3></div>
<div class="form_row">
<div class="form_property form_required">Adınız</div>
<div class="form_value"><input type="text" size="32" name="name" value="" />
</div>
<div class="clearer"> </div>
</div>
<div class="form_row">
<div class="form_property">Email</div>
<div class="form_value"><input type="text" size="32" name="email" value="" /></div>
<div class="clearer"> </div>
</div>
<div class="form_row">
<div class="form_property">Telefon</div> <div class="form_value"><input type="text" size="32" name="website" value="" /></div>
<div class="clearer"> </div>
</div>
<div class="form_row">
<div class="form_property form_required">Mesaj</div>
<div class="form_value"><textarea rows="10" cols="46" name="comment"></textarea></div>
<div class="clearer"> </div>
</div>
<div class="form_row form_row_submit">
<div class="form_value"><input type="submit" class="button" value="Send"/>
<div class="clearer"> </div>
</div>
</fieldset>
</div>
</form>
</body>
</html>
您輸入字段均服務器控件(RUNAT =「服務器」),並使用RequiredFieldValidator也是一個服務器控件,只能驗證服務器控件。 – Matt
你能編輯我的密碼嗎?我不知道如何去做。 – Kaan
[這裏是一個簡單的教程](http://asp.net-tutorials.com/validation/required-field-validator/) – markpsmith