views:

18

answers:

1

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>&nbsp;</td>
            <td colspan="2"><asp:Button ID="ButtonLogon" runat="server" Text="Logon" ValidationGroup="LogonGroup" onclick="ButtonLogon_Click" /></td>
        </tr>
    </table>
</div>

Any ideas?

+1  A: 

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.

KMan
where is the Page.Validate("LogonGroup") put?
Andy Evans
Andy: Please see my edit in response to your comment.
KMan