Auto postback problem with e.g. DropDownList

Discussion in 'ASP .Net' started by Thomas Due, Apr 20, 2004.

  1. Thomas Due

    Thomas Due Guest

    Hello,

    I am in the process of making my asp.net form to validate as xhtml 1.0
    strict. So far I am doing well, but now I have a problem. The problem
    concerns specifically DropDownList and ListBox, but other controls
    might result in the same problem.

    When AutoPostBack is enabled on these controls, two hidden input fields
    are created on the form (__EVENTTARGET and __EVENTARGUMENT),
    furthermore a "postback" javascript is embedded, this javascript looks
    something like this:

    <script language="javascript">
    <!--
    function __doPostBack(eventTarget, eventArgument) {
    var theform;
    if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
    theform = document.forms["MainForm"];
    }
    else {
    theform = document.MainForm;
    }
    theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
    theform.__EVENTARGUMENT.value = eventArgument;
    theform.submit();
    }
    // -->
    </script>

    My problem is that after I converted my forms to xhtml, this javascript
    ceased to work. The error Im getting is: "__EVENTTARGET is null or not
    an object". I suspect it has something to do with the fact that the
    javascript does not conform to the proper syntax and grammar for
    javascript in xhtml. As far as I have learned the proper way to access
    a control is by using "document.getElementById" and not call it
    directly. I can easily change the script to conform, but how do I
    replace the one mentioned above?

    So, my problem is: How do I retain the autopostback functionality on
    e.g. DropDownList but prevents it from registering the javascript?

    --
    Thomas Due
    Software Developer
    Scanvaegt Nordic A/S
    Posted with XanaNews version 1.16.3.1
     
    Thomas Due, Apr 20, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Psych971
    Replies:
    5
    Views:
    4,674
    bruce barker
    Dec 17, 2004
  2. =?Utf-8?B?V2FyYW4=?=

    Auto-Suggested Textbox like google auto suggest

    =?Utf-8?B?V2FyYW4=?=, Apr 20, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    8,571
    inrakeshworld
    Jul 27, 2007
  3. linkswanted
    Replies:
    1
    Views:
    993
  4. cmeek1_1999
    Replies:
    3
    Views:
    4,893
    cmeek1_1999
    Sep 27, 2008
  5. Nishu

    Auto postback in dropdownlist

    Nishu, Sep 6, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    107
Loading...

Share This Page