views:

21

answers:

1

I am currently working on a website using MVC2 and using ASP.NET Ajax to handle moving between pages. Everything is working fine except a page that has a form for the user to fill out that uses DataAnnotations for validation. This form falls within my UpdatePanel and won't conduct server or client side validation, both which I have working if I remove the UpdatePanel.

Is this even possible, or am I missing a step?

Here is a general outline of my code:

<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<form id="form1" runat="server">
<asp:ScriptManager ID="scriptMgr" runat="server" ScriptMode="Release">
</asp:ScriptManager>
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
    <ContentTemplate>
        <div class="page">
            <div id="main">
                <% Html.EnableClientValidation(); %>
                <h2>
                    ContactUs</h2>
                <% using (Html.BeginForm())
                   {%>
                <%: Html.ValidationSummary(true) %>
                <fieldset>
                    <div class="editor-field">
                        <%: Html.TextBoxFor(model => model.Name) %>
                        <%: Html.ValidationMessageFor(model => model.Name) %>
                        <p>
                            <input type="submit" value="Create" />
                        </p>
                </fieldset>
                <% } %>
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
</form>
A: 

Take a look at Ajax.BeginForm instead of using the update panel.

s1mm0t

related questions