Post back not working in Firefox for asp.net pages (C #)

I have a problem with mozilla firefox.

I am developing a website using asp.net language and I have a button in a form. when i clicked on the onclick attributes i call the function and this funtion does the postback.

this scenerio runs chrome and internet service provider. but it doesn't work in Mozilla Firefox. I am getting this error in the console: TypeError: Access to the strict mode call function is censored.

My select button:

<input id="Button1" type="button" onclick="sampleFunc('sample');" value="button" />

      

and my select function:

function sampleFunc(reqMessage)
{
  __doPostBack('', reqMessage);
}

      

I have searched the internet. and many people have a rice problem but no solution.

Do you have a solution for this error (!)

EDIT 1: I found a ticket on the jquery website. According to ticked, tay has fixed this bug. But I applied the same solution, but my error continues. :(

+3


source to share


4 answers


Finally I found the answer.

I am using java library alertfy for popup message. This library uses the expression "Use strict".



And I removed this expression from this library. No problem now. My code works in all browsers.

+2


source


The ASP.Net ScriptManager code pops up the call stack using "caller.callee" in __doPostBack to detect infinite recursion. This will not work on FireFox if any function in the call stack has been parsed using a "use script". A workaround is to have a function outside the scope of the script "that calls setTimeout () to call a function that calls __doPostBack. SetTimeout pops you off the call stack.



+2


source


My advice is to keep javascript and html separate. Instead of using inline call, you can try this method.

Note that jquery must be loaded for this file to work.

eg:

<script>
$(document).ready(function()
{

     $(#Button1).click(function()
      {
        PostBack();

        });

});

</script>
    <input id="Button1" type="button" value="button" />

      

+1


source


It's work around -

Add server side controller to aspx page -

<asp:Button id="btn" runat="server" onclick="btn_click_event" ClientIDMode="static"/>

      

In your code behind the page (aspx.cs), define an event method that will do the actual work after the postback. Now lock this button controller.

<asp:Button id="btn" runat="server" onclick="btn_click_event"  ClientIDMode="static" style="display:none" />

      

Don't use Visible=false

as it just won't display the button at all.

Now change the javascript function to just call click

to `btn '

function sampleFunc()
{
    $('#btn').click();
}

      

And call this function in HTML input buttons on onclick method -

<input id="Button1" type="button" onclick="sampleFunc();" value="button" />

      

0


source







All Articles