Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3053
  • Last Modified:

changing the __doPostBack javascript

Hi all,

review of the problem:

The site I'm working on uses some templating system that force the <form> to a second level in the control tree, so the name and id of my form are not
<form name="myForm" id="myForm">
but
<form name="_ctl0:myForm" id="_ctl0_myForm">

The problem is with netscape, the __doPostBack generated is
     function __doPostBack(eventTarget, eventArgument) {
          var theform = document._ctl0_myForm;
          theform.__EVENTTARGET.value = eventTarget;
          theform.__EVENTARGUMENT.value = eventArgument;
          theform.submit();
     }

which failed in netscape (both 4 and 6)! In fact the document._ctl0_myForm is null. Netscape is for sure looking the names and not the ids to find the object.

During some investigation (hard to find any information related to that problem), I discovered the http://www.asp.net have another __doPostBack script! Here it is:

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

The line with the eventTarget.split("$").join(":") is not related; they changed the default : separator with a $ on the pages (why?).

But what is important is the theForm assignation. I then tried to RegisterClientScriptBlock with that script:
     function __doPostBack(eventTarget, eventArgument) {
          var theform;
          if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
               theform = document.forms["_ctl0_myForm"];
          }
          else {
               theform = document._ctl0_myForm
          }
          theform.__EVENTTARGET.value = eventTarget;
          theform.__EVENTARGUMENT.value = eventArgument;
          theform.submit();
     }

And it 'fixed' my problem but it gives in the page the following code:
<script language="javascript">
<!--
     function __doPostBack(eventTarget, eventArgument) {
          var theform = document._ctl0_myForm;
          theform.__EVENTTARGET.value = eventTarget;
          theform.__EVENTARGUMENT.value = eventArgument;
          theform.submit();
     }
// -->
</script>
<script language="javascript">
<!--
     function __doPostBack(eventTarget, eventArgument) {
          var theform;
          if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
               theform = document.forms["_ctl0_myForm"];
          }
          else {
               theform = document._ctl0_myForm
          }
          theform.__EVENTTARGET.value = eventTarget;
          theform.__EVENTARGUMENT.value = eventArgument;
          theform.submit();
     }
// -->
</script>

The standard __doPostBack followed with my script registration that 'replace' the default one.

I would like to know if there is another way to fix this problem ?
Is there any way to access that __doPostBack script to change it?

/tharn
0
TharnJaggar
Asked:
TharnJaggar
  • 4
1 Solution
 
Zlatin ZlatevTechnical ArchitectCommented:
Another option is to override page render method like in:
http://www.dotnet247.com/247reference/msgs/29/147381.aspx
0
 
Zlatin ZlatevTechnical ArchitectCommented:
Ensure that you have the latest SP (dot NET 1.0 SP2) of .NET Framework
0
 
Zlatin ZlatevTechnical ArchitectCommented:
check here for a solution:
http://www.15seconds.com/issue/030303.htm
0
 
Zlatin ZlatevTechnical ArchitectCommented:
0
 
TharnJaggarAuthor Commented:
The KB is exactely my problem.
Thanks zlatev.

Note: SP2 does not fix the problem. Strange because the KB is related to SP1 so we could think the patch was added to SP2.

/tharn
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now