ASP.NET 提交按钮 requiredFieldValidator 未通过 Facebox 触发

发布于 2024-09-28 21:58:17 字数 1949 浏览 3 评论 0原文

我试图为我正在开发的网站创建一个弹出登录表单,所以我决定尝试一下 Facebox。登录弹出正常,但提交按钮和所需的验证器未触发。它位于母版页内,并包含在进度面板中。

在页眉中,我有:

<script type="text/javascript">
    $(document).ready(function () {
        $('a[rel*=facebox]').facebox();
    });
</script>

在表单顶部,我有此链接:

<a href="#logon_form" rel="facebox">Logon</a>

这是打开下面列出的层:

<div id="logon_form" style="display:none;">
    <table cellpadding="3" cellspacing="0" border="0" class="centered">
        <tr>
            <td>Email:</td>
            <td><asp:TextBox ID="TextLogonEmail" runat="server" CssClass="inputtext" ValidationGroup="LogonGroup" Columns="35" MaxLength="320"></asp:TextBox></td>
            <td><asp:RequiredFieldValidator ID="RequiredLogonEmail" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextLogonEmail" ValidationGroup="LogonGroup" CssClass="error">required</asp:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><asp:TextBox ID="TextLogonPassword" runat="server" CssClass="inputtext" TextMode="Password" ValidationGroup="LogonGroup" Columns="35" MaxLength="40"></asp:TextBox></td>
            <td><asp:RequiredFieldValidator ID="RequiredLogonPassword" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextLogonPassword" ValidationGroup="LogonGroup" CssClass="error">required</asp:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td colspan="2"><asp:Button ID="ButtonLogon" runat="server" Text="Logon" ValidationGroup="LogonGroup" onclick="ButtonLogon_Click" /></td>
        </tr>
    </table>
</div>

有什么想法吗?

I was trying to create a popup logon form for a site I'm working on so I decided to give facebox a try. The logon pops up ok, but the submit button and required validators are not firing. This is within the master page and is contained with a Progress Panel.

In the page header, I have:

<script type="text/javascript">
    $(document).ready(function () {
        $('a[rel*=facebox]').facebox();
    });
</script>

Towards the top of the form, I have this link:

<a href="#logon_form" rel="facebox">Logon</a>

Which is to open the layer listed below:

<div id="logon_form" style="display:none;">
    <table cellpadding="3" cellspacing="0" border="0" class="centered">
        <tr>
            <td>Email:</td>
            <td><asp:TextBox ID="TextLogonEmail" runat="server" CssClass="inputtext" ValidationGroup="LogonGroup" Columns="35" MaxLength="320"></asp:TextBox></td>
            <td><asp:RequiredFieldValidator ID="RequiredLogonEmail" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextLogonEmail" ValidationGroup="LogonGroup" CssClass="error">required</asp:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><asp:TextBox ID="TextLogonPassword" runat="server" CssClass="inputtext" TextMode="Password" ValidationGroup="LogonGroup" Columns="35" MaxLength="40"></asp:TextBox></td>
            <td><asp:RequiredFieldValidator ID="RequiredLogonPassword" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextLogonPassword" ValidationGroup="LogonGroup" CssClass="error">required</asp:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td> </td>
            <td colspan="2"><asp:Button ID="ButtonLogon" runat="server" Text="Logon" ValidationGroup="LogonGroup" onclick="ButtonLogon_Click" /></td>
        </tr>
    </table>
</div>

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴者 2024-10-05 21:58:17

尝试 Page.Validate("LogonGroup"),或者如果您想使用 Javascript 调用它,请尝试:

function myFunction(group)
 {
  if (Page_ClientValidate(group))
     { Something();       }
}

--EDIT--

您可以在 ButtonLogon_Click 事件中提供该内容。就像,

Page.Validate("LogonGroup")
if(Page.IsValid())
{
    //Continue.
}
else
{
    ShowValidationSummary();
}

理想情况下,你的代码应该可以工作。我会添加 ValidationSummary< /a> 在您的 LogonForm Div 中。例如:

<div id="logon_form" style="display:none;">
    <table cellpadding="3" cellspacing="0" border="0" class="centered">
     <tr>
            <td>
<asp:ValidationSummary id="LogonGroup" 
                             DisplayMode="BulletList"
                             EnableClientScript="true"
                             HeaderText="You must enter a value in the following fields:"
                             runat="server"/>
</td>
</tr>
        <tr>
            <td>Email:</td>
            <td><asp:TextBox ID="TextLogonEmail" runat="server" CssClass="inputtext" ValidationGroup="LogonGroup" Columns="35" MaxLength="320"></asp:TextBox></td>
            <td><asp:RequiredFieldValidator ID="RequiredLogonEmail" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextLogonEmail" ValidationGroup="LogonGroup" CssClass="error">required</asp:RequiredFieldValidator></td>
        </tr>
...

因此,当您单击登录按钮时,它将显示验证摘要。

Try Page.Validate("LogonGroup"), or if you want to call it using Javascript, try:

function myFunction(group)
 {
  if (Page_ClientValidate(group))
     { Something();       }
}

--EDIT--

You can provide that inside your ButtonLogon_Click event. Like,

Page.Validate("LogonGroup")
if(Page.IsValid())
{
    //Continue.
}
else
{
    ShowValidationSummary();
}

Ideally, your code should work. I would add the ValidationSummary within your LogonForm Div. For instance like:

<div id="logon_form" style="display:none;">
    <table cellpadding="3" cellspacing="0" border="0" class="centered">
     <tr>
            <td>
<asp:ValidationSummary id="LogonGroup" 
                             DisplayMode="BulletList"
                             EnableClientScript="true"
                             HeaderText="You must enter a value in the following fields:"
                             runat="server"/>
</td>
</tr>
        <tr>
            <td>Email:</td>
            <td><asp:TextBox ID="TextLogonEmail" runat="server" CssClass="inputtext" ValidationGroup="LogonGroup" Columns="35" MaxLength="320"></asp:TextBox></td>
            <td><asp:RequiredFieldValidator ID="RequiredLogonEmail" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextLogonEmail" ValidationGroup="LogonGroup" CssClass="error">required</asp:RequiredFieldValidator></td>
        </tr>
...

So, when you click on the login button, it would show the validation summary there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文