gpt4 book ai didi

.net - .NET webforms 的 HTML5 需要 =""属性

转载 作者:太空狗 更新时间:2023-10-29 13:31:43 26 4
gpt4 key购买 nike

我正在尝试使用新的 required我的 .NET 4.5 webforms 应用程序中表单字段的属性。

但是,由于只有一个 <form>围绕页面上的所有控件(webforms 样式),浏览器不知道在按下提交按钮时要验证哪些字段。

下面附有具有登录功能和页面搜索功能的精简版页面。

当我点击“搜索”按钮时,我的浏览器告诉我必须先填写用户名和密码字段。当我尝试登录时,它告诉我必须在搜索字段中输入一些文本。因为所有字段都是相同 <form> 的子字段标签。

有其他人遇到过这个问题或提出了解决方案吗?我想使用 HTML5 属性进行表单验证,没有 javascript 解决方案。

<!DOCTYPE html>

<html>
<head>
<title>Title</title>
</head>
<body>
<form method="post" runat="server" id="mainform">


<%// Search %>
<asp:Panel runat="server" DefaultButton="searchButton" >

<asp:TextBox runat="server" ID="searchQuery" ClientIDMode="Static" required="required" />
<asp:Button runat="server" ID="searchButton" ClientIDMode="Static" Text="Search"/>

</asp:Panel>


<%// Login %>
<asp:Panel runat="server" DefaultButton="signInButton">

<label for="inputusername">Username</label>
<asp:TextBox runat="server" ClientIDMode="Static" ID="inputusername" required="required" />

<label for="inputpassword">Password</label>
<asp:TextBox runat="server" TextMode="Password" ClientIDMode="Static" ID="inputpassword" required="required" />

<asp:Button ID="signInButton" runat="server" />

</asp:Panel>

</form>
</body>
</html>

</html>

最佳答案

请试试这个..它对我有用..

<asp:TextBox runat="server" 
ClientIDMode="Static"
ID="inputusername"
required />

关于.net - .NET webforms 的 HTML5 需要 =""属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15434535/

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