Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript is Doing a Post on Server Side Twice
    primarykey
    data
    text
    <p>Student Data Grid that display the student id and a description in the grid. It also has a select button when the user click on it that would route to a javascript function. This function will set some flags on the server side, close the window, past the studentID on a search box and do an automatic search on the studentID. The click appears to be doing exactly what I want it to do. However, if the user were to double click on a row in the grid, it is supposed to do the exact same thing. it should also do a post. The double click is doing the post twice. What is causing it to do the post twice? I have not been able to figure it out. I've been putting alert all over the place and no success as to why. </p> <p>In case you may be wondering why I have the dataroute and a client side script. This grid is in a pop up page that is also being called from other pages. When the user calls the grid from another page, the user will have the ability to select multiple records vs. only being able to select one records when they are calling it from the Course Page.</p> <p>Here is the Grid:</p> <pre><code>@(Html .Telerik() .Grid((IEnumerable&lt;OverrideStudent&gt;)SessionWrapper.Student.OtherStudentSelected) .Name("StudentData") .DataKeys(Keys =&gt; { Keys.Add(c =&gt; c.StudentID); }) .DataBinding(databinding =&gt; databinding.Server()) .Columns(columns =&gt; { columns.Bound(p =&gt; p.StudentId) .Title("Student ID") .Width(15) .Sortable(true) .Filterable(false); columns.Bound(p =&gt; p.StudentDescription) .Title("Description") .Width(65) .Sortable(true) .Filterable(false); columns.Command(command =&gt; { command.Custom("AddStudent") .Text("Select") .DataRouteValues(routes =&gt; { routes.Add(o =&gt; o.StudentID).RouteKey("StudentID"); routes.Add(o =&gt; o.StudentDescription).RouteKey("StudentDescription"); }) .Action("Student", "StudentInfo"); .HtmlAttributes(new { onclick = "PostData(this);StudentSelectClick(this)" }); }).Width(20); }).ClientEvents(clients =&gt; clients .OnComplete("OnComplete") //.OnDataBinding("DataBinding") //.OnDataBound("onRowDataBound") .OnRowSelected("StudentDoubleClick") ) .Sortable() .Selectable() .Filterable(filtering =&gt; filtering .Enabled(true) .Footer(true) .HtmlAttributes(new { style = "padding-right: 0.0em;" })) </code></pre> <p>Here are the JavaScripts that are doing the post:</p> <pre><code>function StudentDoubleClick(e) { var fromCourse = "@SessionWrapper.Student.FromCoursePage"; var fromList = "@SessionWrapper.Student.FromListingPage"; if (fromCourse == "True") { $('tr', this).live('dblclick', function () { alert("Inside TR count = " + count); count = count + 1; DoSearchStudent(e); }); } if (fromList == "True") { $('tr', this).live('dblclick', function () { DoSearchStudent(e); }); } } function DoSearchStudent(e) { var row = e.row; var StudentID = row.cells[0].innerHTML; var StudentDescription = row.cells[1].innerHTML; // alert(procCodeDesc); var data = { "StudentID": StudentID, "StudentDescription": StudentDescription, "action": "Double Click" }; var url = '@Url.Action("Student", "StudentInfo")'; $.ajax({ url: url, type: 'post', dataType: 'text', cache: false, async: false, data: data, success: function (data) { window.top.location.href = window.top.location.href; }, error: function (error) { alert("An error has occured and the window will not be closed."); } }); } //Single Click on BUtton function StudentSelectClick(e) { var windows = this.parent.$('#Window').data('tWindow'); var fromCourse = "@SessionWrapper.Student.FromCoursePage"; var fromList = "@SessionWrapper.Student.FromListingPage"; if (fromCourse == "True") { var studentInformation = e.toString(); var data = { "myModel": "null", "studentInformation": studentInformation }; var url = '@Url.Action("UpdatedFromSelect", "StudentProcedure")'; $.ajax({ url: url, type: 'post', dataType: 'text', cache: false, async: false, data: data, success: function (data) { // window.top.location.href = window.top.location.href; windows.close(); // setTimeout(this.window.top.location.href = this.window.top.location.href, 1000); window.top.location.href = window.top.location.href; }, error: function (error) { alert("An error has occured and the window will not be closed."); } }); } } </code></pre> <p>This is the method where the double is being posted to. It simply redirect to a different method of return type ActionResult that also does a redirect to the index page of return ActionResult:</p> <pre><code>public string Student(string StudentID, string StudentDescription, string action) { if (StudentDescription != null) { StudentDescription = HttpUtility.HtmlDecode(StudentDescription); } try { AddStudent(StudentID, StudentDescription, action); } catch (Exception e) { return "Error " + e.ToString(); } return "Success"; } </code></pre> <p>Your help would be greatly appreciated, thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload