ASP.net not generating javascript for some User Agents

后端 未结 6 1260
一整个雨季
一整个雨季 2020-12-20 22:26

********************Edit 2********************** I figured out the problem... But I don\'t like the implications. I was testing our iPhone targeted mobile application earli

相关标签:
6条回答
  • 2020-12-20 23:05

    You have AutoEventWireup set to false, but no Override of OnInit to attach the event. Try changing the AutoEventWireup to true.

    Edit: From the more information it could be that it is incorrectly identifying Firefox in the brower capabilities section of your machine.config. (or web.config).

    It could also be that JavaScript is turned off in Firefox, and thus .NET is determining that there is no point rendering the Javascript stuff, and should use a different approach to postback handling, if there is such a thing.

    0 讨论(0)
  • 2020-12-20 23:07

    The problem is the default way ASP.net treats unknown browsers... such as the iPhone. Even though it would be nice to assume unknown browsers could use javascript... you can specify what capabilities that a browser has in the section of web.config or machine.config.

    Check out http://slingfive.com/pages/code/browserCaps/ for an updated browsercaps config file for asp.net

    Here is an example of a case to match GECKO Based Browsers (Netscape 6+, Mozilla/Firefox, ...)

    <case match="^Mozilla/5\.0 \([^)]*\) (Gecko/[-\d]+)(?'VendorProductToken' (?'type'[^/\d]*)([\d]*)/(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*)))?">
                    browser=Gecko
                    <filter>
                        <case match="(Gecko/[-\d]+)(?'VendorProductToken' (?'type'[^/\d]*)([\d]*)/(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*)))">
                            type=${type}
                        </case>
                        <case> <!-- plain Mozilla if no VendorProductToken found -->
                            type=Mozilla
                        </case>
                    </filter>
                    frames=true
                    tables=true
                    cookies=true
                    javascript=true
                    javaapplets=true
                    ecmascriptversion=1.5
                    w3cdomversion=1.0
                    css1=true
                    css2=true
                    xml=true
                    tagwriter=System.Web.UI.HtmlTextWriter
                    <case match="rv:(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*))">
                        version=${version}
                        majorversion=0${major}
                        minorversion=0${minor}
                        <case match="^b" with="${letters}">
                            beta=true
                        </case>
                    </case>
                </case>
    
    0 讨论(0)
  • 2020-12-20 23:13

    Are you sure you have ASP.NET installed on your web server?

    0 讨论(0)
  • 2020-12-20 23:17

    Before you reinstall Firefox, run it in debug mode (I think it's called debug mode). It turns off all plugins and that can help you narrow it down a bit. What about other browsers like Chrome or Safari?

    0 讨论(0)
  • 2020-12-20 23:23

    Based on the new information, I think it's clear that this is a Firefox problem (perhaps you have an add-on blocking JS), and not a programming question. I get fine results with your code using VS 2008 and FF3 on XP Pro, as I'd expect will most anyone else trying it.

    You may try reinstalling Firefox, ensure that JS works on all other sites, make sure localhost doesn't have different security permissions...

    0 讨论(0)
  • 2020-12-20 23:28

    It looks like the __doPostBack() function is not being generated because you have no server-side events which require it.

    ASP.NET likes to only generate the __doPostBack() function when you have event listeners subscribed that would need it to function correctly.

    0 讨论(0)
提交回复
热议问题