2
我有一個包含幾個文本框的asp.net內容表單。我需要爲這些文本框實現JQuery必需的字段驗證。在下面的代碼中,我無法弄清楚如何使用JQuery來完成它。即使花了一些時間搜索一下,我感到困惑。感謝您的幫助提前如何在ASP.NET內容表單中使用JQuery驗證
<%@ MasterType VirtualPath="~/Shared/Module.master" %>
<%@ Page MasterPageFile="~/Shared/Module.master" Language="C#" AutoEventWireup="true"
CodeFile="CreateObjective.aspx.cs" Inherits="SG.ALD.Schema.Modules.Manage.CreateObjective"
ClientIDMode="Static" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<%@ Register Assembly="SG.Practices.Framework.CoreServices.Client.Web.WebUIControls"
Namespace="SG.Practices.Framework.CoreServices.Client.Web.WebUIControls" TagPrefix="cc1" %>
<%@ Register Src="../../../SharedControl/AuditDataControl.ascx" TagName="AuditDataControl"
TagPrefix="uc1" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="SubModuleContent">
<script type="text/javascript" src="C:\HOMEWARE\Aldschema\trunk\Src\Webserver\WEBUI\Scripts\jquery-1.4.1-vsdoc.js">
PageInitialization();
$('input[id$=txtObjectiveCode]').keydown(function() {
alert('jquery!!!!!!');
});
function PageInitialization() {
PageJQInitialization();
}
function EndRequestHandler(sender, args) {
if (args.get_error() == undefined) {
PageJQInitialization();
}
}
}
</script>
<table border="0" cellspacing="0" cellpadding="0" width="660px" align="center">
<tr>
<td width="5px" class="tableleft">
</td>
<td class="tablemiddle">
<asp:Image runat="server" ID="roleImage" SkinID="gridHeaderImage" /><asp:Label runat="server"
ID="moduleHeaderCaption" />
</td>
<td width="5px" class="tableright">
</td>
</tr>
<tr>
<td valign="top" class="tablelineleft" width="1px">
</td>
<td valign="top" border="0" cellspacing="0" cellpadding="0">
<table width="600px">
<tr>
<td align="center" colspan="2">
<asp:Label ID="lblmsg" runat="server" CssClass="lgt" ForeColor="#CC0000"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 30%" align="right">
</td>
<td style="width: 70%" align="left">
</td>
</tr>
<tr>
<td style="width: 30%; height: 22px;" align="right" class="lgt">
<span runat="server" style="color: #ff0033">*</span>Objective Code:
</td>
<td style="width: 70%; height: 22px;" align="left" class="txtwt">
<asp:TextBox ID="txtObjectiveCode" runat="server" TabIndex="1" MaxLength="50"
SkinID="textboxMandatory" ></asp:TextBox>
<%-- <tr>
<td style="width: 30%" align="right" class="lgt">
<span style="color: #ff0033">*</span> Select City:
</td>
<td style="width: 70%" align="left" class="txtwt">
<div class="mandatoryField" style="width:150px">
<asp:DropDownList ID="drpCity" TabIndex="6" runat="server" AutoPostBack="true" Width="150px" OnSelectedIndexChanged="drpCity_SelectedIndexChanged">
</asp:DropDownList>
</div>
</td>
</tr>
<tr>
<td style="width: 30%" align="right" class="lgt">
<span style="color: #ff0033">*</span> Select Location:
</td>
<td style="width: 70%" align="left" class="txtwt">
<div class="mandatoryField" style="width:150px">
<asp:DropDownList ID="drpSite" Width="150px" TabIndex="7" runat="server">
</asp:DropDownList>
</div>
</td>
</tr>--%> <%-- <tr>
<td style="width: 30%" align="right" class="lgt">
<span style="color: #ff0033">*</span> Select City:
</td>
<td style="width: 70%" align="left" class="txtwt">
<div class="mandatoryField" style="width:150px">
<asp:DropDownList ID="drpCity" TabIndex="6" runat="server" AutoPostBack="true" Width="150px" OnSelectedIndexChanged="drpCity_SelectedIndexChanged">
</asp:DropDownList>
</div>
</td>
</tr>
<tr>
<td style="width: 30%" align="right" class="lgt">
<span style="color: #ff0033">*</span> Select Location:
</td>
<td style="width: 70%" align="left" class="txtwt">
<div class="mandatoryField" style="width:150px">
<asp:DropDownList ID="drpSite" Width="150px" TabIndex="7" runat="server">
</asp:DropDownList>
</div>
</td>
</tr>--%>
</td>
</tr>
<tr>
<td style="width: 30%" align="right" class="lgt">
<span style="color: #ff0033">*</span>Description:
</td>
<td style="width: 70%" align="left" class="txtwt">
<asp:TextBox ID="txtDescription" runat="server" Columns="30" TabIndex="2" MaxLength="25"
SkinID="textboxMandatory" Width="349px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 30%" align="right" class="lgt">
</td>
<td style="width: 70%" align="left" class="txtwt">
</td>
</tr>
<tr>
<td style="width: 30%" align="right" class="lgt">
</td>
<td style="width: 70%" align="left" class="txtwt">
</td>
</tr>
<%-- <tr>
<td style="width: 30%" align="right" class="lgt">
<span style="color: #ff0033">*</span> Select City:
</td>
<td style="width: 70%" align="left" class="txtwt">
<div class="mandatoryField" style="width:150px">
<asp:DropDownList ID="drpCity" TabIndex="6" runat="server" AutoPostBack="true" Width="150px" OnSelectedIndexChanged="drpCity_SelectedIndexChanged">
</asp:DropDownList>
</div>
</td>
</tr>
<tr>
<td style="width: 30%" align="right" class="lgt">
<span style="color: #ff0033">*</span> Select Location:
</td>
<td style="width: 70%" align="left" class="txtwt">
<div class="mandatoryField" style="width:150px">
<asp:DropDownList ID="drpSite" Width="150px" TabIndex="7" runat="server">
</asp:DropDownList>
</div>
</td>
</tr>--%>
<tr>
<td style="width: 30%" align="right" class="lgt">
</td>
<td style="width: 70%" align="left" class="txtwt">
</td>
</tr>
<tr>
<td style="width: 30%" align="right" class="lgt">
</td>
<td style="width: 70%" align="left" class="txtwt">
</td>
</tr>
<tr>
<td style="width: 30%" align="right">
</td>
<td style="width: 0%" align="left">
<table style="width: 100%">
<tr>
<td width="10%">
<asp:Button ID="btnSave" runat="server" TabIndex="10" Text="Save" CssClass="button_70x20"
OnClick="btnSave_Click" AccessKey="a" height="22px" width="71px" />
</td>
<td>
<asp:Button ID="btnCancel" runat="server" TabIndex="11" Text="Cancel" CausesValidation="False"
CssClass="button_70x20 cancel" OnClick="btnCancel_Click" AccessKey="c"
Width="71px" />
<asp:Button ID="btnAudit" runat="server" Text="View Audit" TabIndex="12" CausesValidation="False"
CssClass="button_90x20" OnClick="btnAudit_Click" AccessKey="w"
Visible="False" Width="136px" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top" class="tablelineright">
</td>
</tr>
<tr>
<td class="tablefooterleft">
</td>
<td class="tablefootermiddle">
</td>
<td class="tablefooterright">
</td>
</tr>
</table>
<uc1:AuditDataControl ID="AuditDataControl1" runat="server" />
</asp:Content>
你意識到人們http://pastebin.com網站都得到處都是,沒有必要複製/粘貼在這裏你的整個代碼,只是錯誤的部分。 – balexandre 2012-03-12 07:57:14
您是否找到下面詳細解釋它的鏈接? http://www.zachhunter.com/2010/06/jquery-validation-with-asp-net/ – PraveenVenu 2012-03-12 08:00:39