This is a migrated thread and some comments may be shown as answers.

Window Loses Modal State Upon Validation Errors

5 Answers 76 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chi Sim
Top achievements
Rank 1
Chi Sim asked on 28 Dec 2010, 10:52 AM

I created a modal window using the following codes:

<% Html.Telerik().Window()
.Name("winCreateUser")
.Title("Create New User")
.Modal(true)
.LoadContentFrom(Url.Action("Create", "Users"))
.Draggable(true)
.Scrollable(true)
.Visible(false)
.Width(750)
.Height(500)

%>

<% Html.Telerik().ScriptRegistrar()
.OnDocumentReady(() => {%>
var createWindow = $('#winCreateUser');
var createButton = $('#createUser');

var w = $('#winCreateUser').data('tWindow');

createButton
.bind('click', function(e) {
w.center().open();
createButton.hide();
       
})

.toggle(!createWindow.is(':visible'));

createWindow.bind('close', function() {
createButton.show();
});

<%}); %>

LoadContentFrom property is set to a View (aspx) page containing some strongly-typed user input fields, and the associated validation such as the following:

<%: Html.TextBoxFor(model => model.Username) %>
<%: Html.ValidationMessageFor(model => model.Username) %>

<input type="submit" id="createButton" name="create" value="CreateUser" />

The submit button works fine when all input fields were entered correctly. It closes the window and return back to the main window. However, when there are validation errors occur, the modal window will lose its modal state, and the content is displayed in the main window instead. What did I do wrong? Any suggestion is very much appreciated. Thank you.

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 28 Dec 2010, 03:03 PM
Hi Chi Sim,

Have you attached any JavaScript handlers to the createButton? If not, the data is submitted to the server, instead through an AJAX request (thus the window is hidden). Using client-side validation (step 3 of the blog post) will solve this problem.

Best wishes,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chi Sim
Top achievements
Rank 1
answered on 29 Dec 2010, 10:51 AM
No, I did not attach any Javascript handlers to the createButton. As you suggested, I am using client-side validation as described in the blog you provided. The problem still persists. About the javascript handlers, do I need to do anything about it?
0
Chi Sim
Top achievements
Rank 1
answered on 30 Dec 2010, 08:53 AM
I have double-checked our codes, all validations occur at the client-side. But the window still looses its modal state, becoming a regular content inside the main window. Is there anything I can do to prevent this? Thanks.
0
Alex Gyoshev
Telerik team
answered on 30 Dec 2010, 10:15 AM
Hello Chi Sim,

Can you send us your project (or a sample one that reproduces the issue)? We are not aware of such an issue and need to examine the case in order to fix it.

Greetings,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chi Sim
Top achievements
Rank 1
answered on 30 Dec 2010, 11:16 AM
I have sent a sample project in a support ticket #380087.
Tags
Window
Asked by
Chi Sim
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Chi Sim
Top achievements
Rank 1
Share this question
or