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

Display error message in kendo window

1 Answer 118 Views
Window
This is a migrated thread and some comments may be shown as answers.
sandy
Top achievements
Rank 1
Iron
Veteran
sandy asked on 25 Feb 2021, 06:59 AM

Hi,

i have view with few butons. when i click button am displaying a view in pop up using kendo window.

here i have a form with 2 fields. after entering form data and submit ,in controller action i want to check whether those 2 fileds values are exists.

if exists i want to show error message with values are already exists, i not exists in database then i want to insert those values.

 

below is my code

@(Html.Kendo().Window()
                                                                .Name("AddProjectWindow")
                                                                .Modal(true)
                                                                .Width(750)
                                                                .Height(500)
                                                                .Draggable()
                                                                .Resizable()
                                                                .Title("Add New Project")
                                                                .Actions(actions => actions.Close())
                                                                .LoadContentFrom("AddProject", "Home")
                                                                .Visible(false)
)

 

this is my partial popup view

 

@model Enhancements.Models.Project

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>

<body>
    <div>
        @{
            using (Html.BeginForm("SubmitAddNewProject", "Home", FormMethod.Post, new { id = "basicUsage" }))
            {
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true)
                <table>
                    <tr>
                        <td>Enter Project Code <label style="color:red">*</label></td>
                        <td> @Html.TextBoxFor(x => x.ProjCode)</td>
                        <td>
                            @Html.ValidationMessageFor(m => m.ProjCode, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                    <tr>
                        <td>Enter Project Name <label style="color:red">*</label></td>
                        <td>  @Html.TextBoxFor(x => x.ProjectName)</td>
                        <td>
                            @Html.ValidationMessageFor(m => m.ProjectName, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                </table>
                <div id="message">

                </div>
                <button type="submit" value="Submit" id="btnValidateForm">Submit</button>
            }
        }

    </div>
</body>
@Scripts.Render("~/bundles/jqueryval")


</html>

 

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 01 Mar 2021, 12:37 PM

Hello Sandy,

We have a sample application demonstrating how you can use Kendo Window and load partial views that utilize Ajax.BeginForm helper. You can review the application here:

https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/window/KendoWindow-Ajax-Form

You can further customize the behavior by handling the ajax submit and the error and success callbacks. On success, when no duplicate entries are available, you can close the window, otherwise you can display an error message to the user.

I hope the above example helps you implement the desired functionality.

Regards,
Aleksandar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Window
Asked by
sandy
Top achievements
Rank 1
Iron
Veteran
Answers by
Aleksandar
Telerik team
Share this question
or