Page not rendering in Window after OnPost

1 Answer 232 Views
Window
randy2101
Top achievements
Rank 1
randy2101 asked on 06 Sep 2022, 09:08 PM

Howdy

I am opening a window to display a razor page using the following


function dblClickCalEvent(e) {

		var win = $("#scheduleWindow").data("kendoWindow");

		win.refresh({
			url: "@Url.Page("ScheduleForm", "Details")",
			data: { clickDate: e.dataset.clickdate, scheduleId: e.dataset.scheduleid }
		});
		win.center().open();

	}

This opens the Razor page and calls the OnGetDetails and renders the page using the correct Model.  I have a MultiSelect on the page using the Select Event which once a value is selected POSTs back to the page using the following:




	function attendee_selected(e) {


		$.ajax({
			type: "POST",
			url: "ScheduleForm?handler=AttendAdd",
			data: { __RequestVerificationToken: '@token', attendee: e.dataItem.UserPrincipleName }
		});


	}

Which posts to this:


public async Task<IActionResult> OnPostAttendAdd(string attendee)

And returns Page();

I can see that the model gets populated while debugging the Razor page, however the page never renders the new results on page.  I have tried to call a refresh on the window but this has no effect.  Here is and example of where the ViewDates change once the Page is returned from the Post method and the changes are not reflected in the page in the window:


<table style="width: 100%;">
				<tr>
					@foreach (var d in Model.ScheduleAssistaint.ViewDates)
					{

						<td class="border1" style="text-align:center;">
							@d.ToLongDateString()
						</td>

					}
				</tr>
			</table>

Is this something to do with the fact the page is inside a window?  If so is there a way to fix this?

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 09 Sep 2022, 01:16 PM

Hi Randy,

Thank you for reaching out.

I noticed that there is not a Telerik UI for ASP.NET Core license associated with your account which limits the availability of our support services for the product. In this regard, It is recommended that you either purchase or renew your license in order to gain access to the latest updates, fixes, features, and support regarding the Telerik UI for ASP.NET Core components. More information regarding the currently available plans can be reviewed here:

Nevertheless, a possible for you to try would be to wire to the success() callback method of the ajax's request whilst obtaining the rendered result of the page.

From there, I would recommend getting the rendered Window DOM element and replacing its content with the conventional .replaceWith() method. This would be required as indeed, upon your observations the window's object reference would not be available on-the-fly.

Here is an exemplary implementation of the suggested above:

function attendee_selected(e) {
	$.ajax({
		 type: "POST",
		 url: "ScheduleForm?handler=AttendAdd",
		 data: { __RequestVerificationToken: '@token', attendee: e.dataItem.UserPrincipleName },
                 success: function(result) {
                          var container = $("body").find("#scheduleWindow");
                          container.replaceWith(result);
                 }
        });
}

Kind Regards,
Alexander
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Tags
Window
Asked by
randy2101
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or