删除,替换或禁用动态生成的ASP.Net js代码 [英] Remove, replace or disable dynamically-generated ASP.Net js code

查看:99
本文介绍了删除,替换或禁用动态生成的ASP.Net js代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一些.Net 4.0 Webforms控件(例如Menu控件),虽然我认为现在可以声明控件的呈现方式(即表或div)是一件很棒的事情,但我不能关闭管理这些控件的悬停事件的自动添加的javascript,例如:

I am working with a few .Net 4.0 webforms controls such as the Menu control and while I think it's great that I can now declare the way in which controls are rendered (i.e. as either tables or divs), I can't switch off the automagically-included javascript that manages the hover events for those controls, for example:

new Sys.WebForms.Menu({ element: 'NavigationMenu', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false }

这显示在拥有此类控件的每个页面的底部。

This appears at the bottom of every page that owns such a control.

鉴于无法真正关闭此控件,最好的方法是是禁用该脚本,覆盖它还是以其他方式使其变得无能为力,以便我可以在其位置定义自己的jQuery方法?

Given there is no way to actually switch this off, what is the best approach to either disabling this script, overriding it or in some other way rendering it impotent so that I can define my own jQuery methods in its place?

推荐答案

好吧,您可以尝试的是在包含Webforms脚本之后添加一些JavaScript,以执行以下操作:

Well, what you can try is include some javascript after the Webforms scripts are included that does the following:

Sys.WebForms.Menu = function() {};

基本上,这会覆盖webforms菜单javascript,而不会执行任何操作。不过要小心,特别是如果您正在使用这些菜单的现有项目中工作,因为它们不再是javascript。

Basically, that overrides the webforms Menu javascript to do nothing. Be careful though, especially if your working on an existing project that uses these menus already, as they're javascript will no longer work.

个人而言,我建议您创建一个自己的菜单标记,css和javascript,使用更精简的控件(如Repeater或ListView)。这样可以避免大多数此类问题,并且您将对输出有更多的控制权。

Personally, I would recommend creating your own menu markup, css and javascript using a much "leaner" control like the Repeater or ListView. This would avoid most of these issues and you would have much more control over the output.

这篇关于删除,替换或禁用动态生成的ASP.Net js代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆