ASP.net not generating javascript for some User Agents

被刻印的时光 ゝ 提交于 2019-11-29 14:24:18

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>

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?

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...

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.

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!