1

I have a webpart that has a search bar. In the Internet Explorer it works fine.

normal

But when the user writes a text in the search bar of the webpart in Google Chrome, the site refreshes and the web part opens in Edit Mode:

editmode

I looked at the code and this is what happens, when the user write something in the search bar:

outHtml += '<td >&nbsp;Suche</td><td width="170px"><input onkeyup="startSearch()" id="Suche" type="text" ></td>';

This is the startSearch method:

function startSearch() {
    delay(function () {
        loadList();
    }, 1500); 
}

and this is the loadList function:

function loadList() {

    var query = getQuery();
    var select = "$select=Id,ITKennung,Nachname,Vorname,Personalnummer,Kostenstelle,Abteilung,Standort,Telefonnummer,Status,Vorgesetzter/Title";
    var expand = "&$expand=Vorgesetzter";
    var order = "&$orderby=Nachname asc&$top=10000";
    query = "?" + select + expand + query + order;

    //if (query != "") {
    $.jgrid.gridUnload('gridMitarbeiter');
    loadGrid("Mitarbeiter", query + "", "gridMitarbeiter", cnEmployees, cmEmployees);
    //}
}

How can one fix this fatal bug?

2

I had the exact same issue some time ago.

Some users were actually getting a permissions issue, since the page tries to go into edit mode and they don't have access to edit pages.

This was the solution I found.

<script>
    function WebForm_OnSubmit() {
        return false;
    }
</script>

If you just want to prevent a special event from triggering the edit mode, you can also try,

<input onkeyup="startSearch(); return false;" id="Suche" type="text" >

Edit mode with the Enter Key

2
  • Thanks. Where do I have to write that in the code? Mar 10 '20 at 10:39
  • you basically need to stop the page from posting back when you press enter. you either do it globally using the top script, or tweak your onkeyup so that it returns false. answer updated. these scripts can go alongside your existing code Mar 10 '20 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.