Vb.net, javascript issue including strict mode

I have a VB.net application that I am trying to integrate with the previous deverlopers code. The code takes a zipcode and returns a list of stores along with their location on the google map canvas.

The process works great, with one exception.

I get the following error

JavaScript runtime error JavaScript: access to the 'caller' property of a function or argument is not allowed in strict mode.

I isolated the culprit from

__doPostBack('userControlSearchResults_results', LatLng);

What is inside

function Sys$WebForms$PageRequestManager$_doPostBack(eventTarget, eventArgument) {
        var event = window.event;
        if (!event) {
            var caller = arguments.callee ? arguments.callee.caller : null;
            if (caller) {
                var recursionLimit = 30;
                while (caller.arguments.callee.caller && --recursionLimit) {
                    caller = caller.arguments.callee.caller; // ERRORS HERE
                }
                event = (recursionLimit && caller.arguments.length) ? caller.arguments[0] : null;
            }
        }
    ...

My first inclination was to create window.event so that it would pass an if (!) Event and move on. Since there are other times, we call __doPostback in the code, and it succeeds.

However, since my JavaScript is limited, I either do it wrong or have to find a different approach.

. - " "; .

, JavaScript, " "

- , ?

setTimeout() __doPostback. , -.

: .

__ doPostback javascript

function CompleteSearch(returnedLatLng) {

    if (returnedLatLng != '') {
        alert("dopostback here2- this is where it breaks");
        __doPostBack('ucSearchResults_udpResults', returnedLatLng);
        if (document.getElementById("sidebar_search")) { document.getElementById("sidebar_search").style.display = "none" };
        if (document.getElementById("sidebar_login")) { document.getElementById("sidebar_login").style.display = "none" };
        if (document.getElementById("promo1")) { document.getElementById("promo1").style.display = "none" };
        document.getElementById("sidebar_results").style.display = "block";
        //document.getElementById("sidebar_results").style.display = "none";
    }
    return false;
}

:

<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div id="Container" style="zoom:1" onclick="">
    <asp:UpdatePanel runat="server" ID="udpResults" OnLoad="UpdatePanel1_Load">
        <ContentTemplate>
            <asp:HiddenField ID="currentLatLong" runat="server" />
            <asp:HiddenField ID="triggerSearch" runat="server" Value="0" />
            <asp:HiddenField ID="searchString" runat="server" Value="0" />

            <asp:HiddenField ID="locationCode" runat="server" />
            <asp:HiddenField ID="locationDesc" runat="server" />
            <asp:HiddenField ID="locationPhone" runat="server" />
            <asp:HiddenField ID="locationZip" runat="server" />

            <asp:HiddenField ID="filterPickup" runat="server" />
            <asp:HiddenField ID="filterVirtualKiosk" runat="server" />
            <asp:HiddenField ID="filterDelivery" runat="server" />
            <asp:HiddenField ID="filterAcceptsCash" runat="server" />
            <asp:HiddenField ID="filterKey2Key" runat="server" />
            <asp:HiddenField ID="filterHODService" runat="server" />

            <asp:Label ID="tblResults" runat="server"></asp:Label>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>
</form>

. , .

+4
2

, window.event null.

, null JavaScript.
, .

2 .

A:

1/ : , , 2/ : __doPostBack

- .
, objet .
, window.event .
, , .

window.event, null, - .

B:

UpdatePanel input type="submit", __doPostBack .
.

UpdatePanel , :

var btn = document.createElement('INPUT');  
btn.setAttribute('name', 'timer_dummy_button');  
btn.setAttribute('type', 'submit');  
btn.setAttribute('value', 'what you like');  
btn.setAttribute('style', 'display:none;');  
document.getElementById('yourNiceLittleUpdatePanelID').appendChild(btn);  
btn.click();

postback, Page.Request.Form :

["yourNiceLittleScriptManagerControlID"] = "yourNiceLittleUpdatePanelID|timer_dummy_button"  
["__EVENTTARGET"] = ""  
["__EVENTARGUMENT"] = ""  
["timer_dummy_button"] = "what you like"  
+2

, Javascript Sys $WebForms $PageRequestManager $_doPostBack , , ASP-. , ASP, , userControlSearchResults_results.

, __doPostBack. , .

__doPostBack()

0

Source: https://habr.com/ru/post/1537781/


All Articles