Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7404411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:15:08+00:00 2026-05-29T05:15:08+00:00

Apologies in advance if this becomes a very long question… Background Info I have

  • 0

Apologies in advance if this becomes a very long question…

Background Info

I have an MVC 3 application, using Telerik components and this particular issue is specific (I think) to the Window() component.

From my main view (Index.cshtml) I executing an ajax request to return a partial view which is what I am populating the contents of my window with. This is the jquery which is executing the request:

var url = '@Url.Action("GetAddPart", "Jobs")';            
var window = $("#Window").data("tWindow");
var data = $("#indexForm").serialize();
window.ajaxRequest(url, data);
window.center().open();

the controller action is:

[HttpGet]
public ActionResult GetAddPart(MDTCompletedJobM model)
{
    // show the AddPart window

    //TryUpdateModel<MDTCompletedJobM>(model);
    model.ActionTakenList = ActionTakenList;
    model.ProblemTypes = ActualProblemList;
    var addPartM = new MDTAddPartM() { CompletedJobM = model };
    return PartialView(string.Concat(ViewDefaultUrl, "AddPart.cshtml"), addPartM);
}

this opens my window hunky dory.

in my partial view i have a form with two or three fields and an “Add”, “Cancel button. For the sake of brevity I’ll just show what I think are the relevant parts of the partial view, but i can produce the entire view if need be:

<div id="resultDiv">
    @using (Html.BeginForm("AddPart", "Jobs", FormMethod.Post, new { id = "addPartForm", name = "addPartForm" }))
    { 

             ** layout components removed from here **

        <input type="button" value="Add" class="t-button" id="btnAdd"/>
        <input type="button" value="Cancel" class="t-button" id="btnCancel"/>

        <p />
        <div id="progressdiv">
        </div>

    }    
</div>

is the “top level” tag in the partial view.

my jquery to handle the Cancel button is:

$("#btnCancel").click(function () {
    var window = $("#Window").data("tWindow");
    window.close();
});

In my main view, I have a submit button, which when completed effectively reders the main view “disabled” or displays errors. The action for this submit button returns the main view:

Controller's action snippet:
            if (ViewData["DoPayJobWarningStr"] == null)
                return RedirectToAction("GetAutoDispatchJob", new { autoDispatchJob = model.JobReferenceNumber});
            else
                return View(string.Concat(ViewDefaultUrl, "Index.cshtml"), tmpModel);

My actual problem

For a specific example I am using, I am expecting ViewData[“DoPayJobWarningStr”] NOT to be null, there the return View(…) will be executed.

if I execute this action (for the submit button) without opening the window, my view returns correctly and the page is updated to show the warning message. However, if I open the window first then execute the submit button, the View isn’t updated on the page, but seems to be placed into the Window’s html. ie, if I hit the submit button (nothing happens), then click on the button which opens the Telerik window, I briefly see the View returned by the submit Action being shown before it’s updated with what the Partial View should contain. I don’t understand at all how or why the returned View is being placed there?

Things I’ve tried:

  1. Commenting out the ajax request (window.ajaxRequest(url, data);) fixes the issue (even though I obviously have a blank partial view to look at).
  2. Not making the Partial View a “Form” doesnt’ work
  3. No matter how I “close” the window, the view is still placed within there. eg clicking the x in the top right hand corner
  4. Using Firebug, the HTML after the submit button is clicked is not updated.
  5. Rather than using “window.ajaxRequest(url, data)”, i’ve also tried (with the same result):

    $.ajax({
        type: "GET",
        cache: false,
        url: url,
        data: $("#indexForm").serialize(),
        success: function (data) {
            var window = $("#Window").data("tWindow");
            window.content(data);
            window.center().open();
            $("#progress").html('')
        },
        error: function (e) {
            alert(e.Message);
        }
    });
    

Is it all possible to determine what I am doing wrong? Is it the ajax request? Only assuming that because removing it fixes the issue, but there might be more to it than that.

Thanks and of course if you need more info, ask 🙂

Thanks

EDIT

After suggestions from 3nigma, this is what I’ve updated to (still no luck)…

Telerik window definition:

@{Html.Telerik().Window()
    .Name("Window")
    .Title("Add Part")
    .Draggable(true)
    .Modal(true)
    .Width(400)
    .Visible(false)
    .Height(270)
    .ClientEvents(e => e.OnOpen("onWindowOpen"))
    .Render();
}

jquery function which is an OnClick event for a button:

function AddBtnClicked() {
    $("#Window").data('tWindow').center().open();
}

the onWindowOpen event:

function onWindowOpen(e) {
    //e.preventDefault();

    var data = @Html.Raw(Json.Encode(Model));
    var d2 = $.toJSON(data);

    $.ajax({
        type: 'GET',
        url: '@Url.Action("GetAddPart", "Jobs")',
        data: d2,
        contentType: 'application/json',
        success: function (data) {
            var window = $("#Window").data("tWindow");
            window.content(data);
            $("#progress").html('');
        },
        error: function (xhtr, e, e2) {
            alert(e +'\n' + xhtr.responseText);
        }
    });
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:15:08+00:00Added an answer on May 29, 2026 at 5:15 am

    OK.

    Issue was related to this line in the Partial View:

    <script src="@Url.Content("~/Scripts/ValidationJScript.js")" type="text/javascript"></script>
    

    As soon as I took that out, it all works. Not sure why that was causing the issue – I don’t think it had been previously been loaded but maybe it had which was causing the problem.

    Thanks to 3nigma for your thoughts, nonetheless!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies in advance for the length of this question! I have a data structure
Apologies in advance if this question is badly worded! I have a MySQL table
Apologies in advance if this is a silly question, am very much a beginner.
This is a very wide-ranging/vague question, but here goes. Apologies in advance. The app
This may be a very simplistic question, so apologies in advance, but I am
Apologies in advance for the long-winded question. I'm really a database programmer, but have
Apologies in advance, because I suspect this may be a silly question. I have
All, Apologies in advance - this question might be too open-ended for SO. Anyway...
This may be a bit of an abstract question, so apologies in advance. I
This, I'm sure is a pretty basic question about JavaScript, so apologies in advance.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.