gpt4 book ai didi

html - WebForms UnobtrusiveValidationMode 需要 'jquery' 的 ScriptResourceMapping。请添加一个名为 jquery 的 ScriptResourceMapping(区分大小写)

转载 作者:IT老高 更新时间:2023-10-28 11:01:38 25 4
gpt4 key购买 nike

我正在使用 Visual Studio 2012 构建一个 Web 应用程序。我正在尝试将字数添加到我的文本框中。但是在添加了 javascript 代码和 html 代码之后。我收到上述错误。

这是我的 javascript 代码

代码:

function validateLimit(obj, divID, maxchar) {

objDiv = get_object(divID);

if (this.id) obj = this;

var remaningChar = maxchar - trimEnter(obj.value).length;

if (objDiv.id) {
objDiv.innerHTML = remaningChar + " characters left";
}
if (remaningChar <= 0) {
obj.value = obj.value.substring(maxchar, 0);
if (objDiv.id) {
objDiv.innerHTML = "0 characters left";
}
return false;
}
else
{ return true; }
}

function get_object(id) {
var object = null;
if (document.layers) {
object = document.layers[id];
} else if (document.all) {
object = document.all[id];
} else if (document.getElementById) {
object = document.getElementById(id);
}
return object;
}

function trimEnter(dataStr) {
return dataStr.replace(/(\r\n|\r|\n)/g, "");
}

母版页中的服务器代码

<script type="text/javascript" src="js/JScript.js" ></script>

ASPX 代码,(Html 代码)

<tr>
<th style="width: 595px; height: 135px;">Official Report :</th>
<td colspan="4" style="height: 135px">
<asp:TextBox ID="tbofficial" runat="server" Height="121px" TextMode="MultiLine" Width="878px" MaxLength="500" ToolTip="Summary:(500 characters)" onkeyup="return validateLimit(this, 'lblMsg1', 500)" ></asp:TextBox>
<div id="lblMsg1">500 characters left</div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="tbofficial" Display="Dynamic"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
<br />
<asp:Label ID="lblmsg" runat="server"></asp:Label>
<br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
<asp:Button ID="btnClear" runat="server" Text="Clear" OnClick="btnClear_Click" />
</td>
</tr>

最佳答案

您需要一个 web.config key 来启用 4.5 之前的验证模式。

更多信息 ValidationSettings:UnobtrusiveValidationMode :

Specifies how ASP.NET globally enables the built-in validator controls to use unobtrusive JavaScript for client-side validation logic.

Type: UnobtrusiveValidationMode

Default value: None

Remarks: If this key value is set to "None" [default], the ASP.NET application will use the pre-4.5 behavior (JavaScript inline in the pages) for client-side validation logic. If this key value is set to "WebForms", ASP.NET uses HTML5 data-attributes and late bound JavaScript from an added script reference for client-side validation logic.

Example:

    <appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>

关于html - WebForms UnobtrusiveValidationMode 需要 'jquery' 的 ScriptResourceMapping。请添加一个名为 jquery 的 ScriptResourceMapping(区分大小写),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16660900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com