0
votes
function my_page_start_onload() {
    if (__doPostBack) { //  Error: '__doPostBack' is undefined
        ...
    }
}
window.onload = my_page_start_onload();

I have tried many ways but with no luck.

  1. Control Panel -> Windows Update -> is up-to-date -> still error
  2. Browser Definition Updated (aspnet_regiis.exe -i and iisreset) -> see http://forum.jdp.tw/thread-1552-1-1.html -> Added browser definition to C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\Browsers\ie.browsers -> RUN C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regbrowsers.exe -i -> RUN iisreset -> still error

  3. Try to install hotfix, but occurs an error The update is not applicable to your computer

  4. Try to install .NET Framework, but occurs an error The update is not applicable to your computer

  5. VS2012 with .NET 4.5 to run this function with blank page, still error

  6. All versions of IE5-11, still error

Remarks:

  1. Request.Browser.Browser returns InternetExplorer
  2. Request.Browser.Version returns 11.0

Computer Environment

  1. windows 7 64-bit
  2. VS2008 with .NET 3.5
  3. IIS 7.5' application pool use .NET v2.0 version
  4. IE11.

Many thanks for help!

1
Have you searched here for __doPostBack undefined - and read this stackoverflow.com/questions/15273618/…Jaromanda X
Yes, I have tried and I think the problem is not related to browser definition. because Request.Browser.Browser and Request.Browser.Version return IE11. And also using VS2012 with .NET4.5 to run window.onload = my_page_start_onload(); with blank page, but still error.Yves

1 Answers

0
votes

Postback function will be automatically generated for you by .NET if your page contains some control that requires postback, but don't normally cause postback. Consider a submit button - it causes postack, but don't need additional js code because it's designed to cause postback. However, controls like linkbutton (rendered as anchor) or dropdownlist don't normally cause postback that's why asp.net will generate __postback function for them. So in order to force asp.net to generate _postback function you can add to page some dummy control or you can make <form> tag runat=server or if you want to include __postback function in every page no matter what controls they contrains you can execute this function in your master page Page_Load event:

ClientScript.GetPostBackEventReference(this, "");