I have a Window which has an Ajax Form with a button. The first time submit is pressed, it calls the controller once as expected. However, the second time the button is pressed, the controller is called 3 times. The third time the button is pressed, it is getting called 8 times.
So something is clearly wrong. The Ajax call replaces the div (which has the button) so it appears the button is getting wired up multiple times, once for each ajax call.
This is the partial view that is called.
If there is some other way I should be done this, I would be glad to hear about it.
Greg
So something is clearly wrong. The Ajax call replaces the div (which has the button) so it appears the button is getting wired up multiple times, once for each ajax call.
@(Html.Kendo().Window()
.Name("loginWindow") //The name of the window is mandatory. It specifies the "id" attribute of the widget.
.Title("Login") //set the title of the window
.Content(@<
text
>
@Html.Partial("_LoginPartial")
</
text
>)
.Draggable() //Enable dragging of the window
.Width(300)
.Height(350)
.Modal(true)
.Visible(false)
)
@model NTC.PropertySearch.Models.LoginModel
@{
ViewBag.Title = "Log in";
}
<
section
id
=
"loginWindow"
>
@using (Ajax.BeginForm("Login", "Account", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "loginSection", }))
{
<
div
id
=
"loginSection"
>
@ViewBag.Title
<
div
>
<
p
>
@Html.DisplayFor(m => m.Message)
</
p
>
<
p
>
@Html.DisplayFor(m => m.NumberOfLoginAttempts)
</
p
>
</
div
>
<
table
>
<
tr
>
<
td
>@Html.LabelFor(m => m.UserName)
</
td
>
</
tr
>
<
tr
>
<
td
>
@Html.TextBoxFor(m => m.UserName)
</
td
>
</
tr
>
<
tr
>
<
td
>
@Html.ValidationMessageFor(m => m.UserName)
</
td
>
</
tr
>
<
tr
>
<
td
>
@Html.LabelFor(m => m.Password)
</
td
>
</
tr
>
<
tr
>
<
td
>
@Html.PasswordFor(m => m.Password)
</
td
>
</
tr
>
<
tr
>
<
td
>
@Html.ValidationMessageFor(m => m.Password)
</
td
>
</
tr
>
<
tr
>
<
td
>
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe, new { @class = "checkbox" })
</
td
>
</
tr
>
</
table
>
<
input
type
=
"submit"
value
=
"Log in"
/>
</
div
>
}
</
section
>
Greg