Remove, replace, or disable dynamically generated ASP.Net js code

I work with several elements of .Net 4.0 web forms, such as a menu control, and although it seems to me that I can now declare a way to render the controls (i.e. like tables or divs), I cannot turn off the automatically enabled javascript that manages hover events for these controls, for example:

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

This is displayed at the bottom of each page to which such a control belongs.

Given that there is no way to disable this, the best way to disable this script, override it, or in some other way make it impotent so that I can define my own jQuery methods in place?

+1
source share
2 answers

Well, what you can try is to enable some javascript after enabling Webforms scripts, which does the following:

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

Basically, this overrides the javascript menu of webforms to do nothing. Be careful, especially if you are working on an existing project that uses these menus already, since javascript no longer works.

Personally, I would recommend creating your own menu markup, css and javascript using a much more "tougher" control, such as Repeater or ListView. This will avoid most of these problems, and you will have much more control over the exit.

+2

( ) .

Phil.Wheeler, Sitemap. , 3.5 - , script Sys.WebForms.Menu .

:

aspx:

<script type='text/javascript'>new Sys.WebForms.Menu({ element: 'ctl00_MainNavMenu', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false });</script>

'ct100_MainNavMenu', javascript MenuStandards.js, tagName === 'DIV'. this.element null.

Sys.WebForms.Menu = function(options) {
    this.items = [];
    this.depth = options.depth || 1;
    this.parentMenuItem = options.parentMenuItem;
    this.element = Sys.WebForms.Menu._domHelper.getElement(options.element);
    if (this.element.tagName === 'DIV') {
        var containerElement = this.element;
        this.element = Sys.WebForms.Menu._domHelper.firstChild(containerElement);
        this.element.tabIndex = options.tabIndex || 0;
        options.element = containerElement;
        options.menu = this;
        this.container = new Sys.WebForms._MenuContainer(options);
        Sys.WebForms.Menu._domHelper.setFloat(this.element, this.container.rightToLeft ? "right" : "left");
    }
    else {
        this.container = options.container;
        this.keyMap = options.keyMap;
    }

ASPX, html , ( ):

<div id="ctl00_MainNavMenu" style="display:none">
    <div id="neededToPreventSecondErrorAt_tabIndex"></div>
</div>

HTML :

<div id="ctl00_MainNavMenu" style="display: none; float: left;">
    <div tabindex="0" role="menubar" class="static" style="position: relative; width: auto; float: left;"></div>
</div>

- ASPX, IE, FF Chrome. , , . , , . , /, javascript -.

+1

All Articles