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

Telerik Popup Modal Window Will not close

1 Answer 219 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mitch
Top achievements
Rank 1
Mitch asked on 23 Mar 2013, 04:09 AM
I have a telerik popped up window. It opens fine; however, I am having an issue closing the window. 


Here is the popup window:


@{Html.Telerik().Window()
         .Name("Window")
         .Title("Student Window")
         .LoadContentFrom(Url.Action("AddReason", "Reason", new { id = reasonID }, Request.Url.Scheme))
         .ClientEvents(events => events
             .OnClose("ClosingWindow")
             )
         .Draggable(false)
         .Scrollable(false)
         .Width(800)
         .Height(600)
         .Modal(true)
         .Visible(false)
         //.Effects(fx => fx           
         //    .Zoom()           
         //    .Opacity())
         .Render();
     }

here is the reference for the javascript:
<script src="@Url.Content("~/Scripts/jquery-1.4.4.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/spin.min.js")" type="text/javascript"></script>

Here is the JavaScript:
function DoOpen(id) {
        var url = '@Url.Action("AddReason","Reason")';
        $.post(url, { id: id }, function (data) {
            var window = $('#Window').data('tWindow').center();
            window.content(data);
            window.open();
        });
   }
 //This javascript is in the main page
//I did an alert. alert($('#Window')) and 
alert($('#Window').data('tWindow')) they both return null

  function ClosingWindow() {
      $('#Window').prop("checked", "checked");
      $('#Window').data('tWindow').close();
       window.location.href = window.location.href;
   }

Here is the partial view :
@model Student.Models.Reason
@using Student.Example
 
@{
    ViewBag.Title = "Add Reason";
    Layout = "~/Views/Shared/_PartialReason.cshtml";
}
 
<script type="text/javascript">
    function CloseWindow() {
//        alert($("#Window").closest('.t-window').data('#tWindow'));
//        $("#Window").data("tWindow").close();
        $('#Window').prop("checked", "checked");
         window.location.href = window.location.href;
    }
 
</script>
 
@using (Html.BeginForm("AddReason", "Reason", FormMethod.Post))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <div class="editor-field">
            @(Html.Telerik().Editor()
            .Name("EncountersArchive")
            .HtmlAttributes(new { style = "height:310px;", id = "AddAReason" })
            .Encode(true)
            .Tools(
            tools => tools
                       .Clear()
                        .Bold().Italic().Underline().Strikethrough().Subscript().Superscript().Separator()
                        .FontName().FontSize()
                        .FontColor().BackColor().Separator()
                        .JustifyLeft().JustifyCenter().JustifyRight().JustifyFull().Separator()
                        .InsertUnorderedList().InsertOrderedList().Separator()
                        .Indent().Outdent().Separator()
            ))
        </div>
        <p style="text-align:center">
              
            <input type="submit" value="Reason" id="AddReasonID" onclick="CloseWindow()"/>
        </p>
    </fieldset>
}


Amanda
Top achievements
Rank 1
commented on 29 Oct 2024, 01:03 PM

Does anyone work here
Rumen
Telerik team
commented on 29 Oct 2024, 02:11 PM

Hi Amanda,

Thank you for reaching out! I’d like to help clarify your question.

Could you let us know if you're experiencing an issue with the RadWindow control part of the Telerik UI for ASP.NET AJAX suite or if the issue is with a Window control in Telerik UI for ASP.NET MVC? The code shared in this AJAX forum seems to be for the MVC suite, so knowing the exact product you're working with will help us provide the most accurate guidance. Additionally, it would be helpful if you could share your specific scenario and relevant code.

Looking forward to your response!

1 Answer, 1 is accepted

Sort by
0
Mitch
Top achievements
Rank 1
answered on 23 Mar 2013, 01:50 PM
I tried this morning use the $('#Window').closet('.t-window').data('tWindow').close() with no help still.
Tags
General Discussions
Asked by
Mitch
Top achievements
Rank 1
Answers by
Mitch
Top achievements
Rank 1
Share this question
or