Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 2.0 runtime javascript error - WebForm_PostBackOptions is undefine

Reply
Thread Tools

2.0 runtime javascript error - WebForm_PostBackOptions is undefine

 
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      01-10-2006
I am converting my enterprise solution from VS 2003 (.NET v1.1.4322) to VS
2005 (.NET v2.0.50727). The entire solution uses serveral technologies -
Windows Server 2003 (AD, SQL Server 2000, IIS, ASP.NET, ASP.NET Mobile)
Windows Mobile 2003 (Pocket IE)

I have completed a portion of the conversion (ASP.NET Mobile pages for PIE,
and some of the ASP.NET-bases web services), and while
testing I have a runtime error that did not exist in the 1.1 version.
It is associated with a Windows Mobile ObjectList (mobile:ObjectList )
When debugging on the desktop in IE 6.0 (I have *not* yet started conversion
testing with PIE on the PDA), I click on a linkbutton in the object list and
now receive a JavaScript error -
WebForm_PostBackOptions is undefined.

I am not using Javascript explicitly in my code, the error is caused by
ASP.NET 2.0-generated Javascript.
My .aspx code for LinkButtons in the ObjectList looks like -
(<asp:LinkButton ID="lbnTask" CommandName="details" Runat="server"><%#
((ObjectListItem)Container)["name"] %></asp:LinkButton>)

ASP.NET 2.0 generates javascript for the browser that looks like -
<TD><a id="olstTask__ctl1_lbnTask"
href="javascript:WebForm_DoPostBackWithOptions(new
WebForm_PostBackOptions("olstTask:_ctl1:lbnTask", "", true, "", "", false,
true))">medicate patient</a></TD>

Previously, ASP.NET 1.1 generated javascript for the browser that looks very
similar -
<TD><a id="olstTask__ctl1_lbnTask"
href="javascript:WebForm_DoPostBackWithOptions(new
WebForm_PostBackOptions("olstTask:_ctl1:lbnTask", "", true, "", "", false,
true))">medicate patient</a></TD>

I know there is JavaScript embedded in System.Web.dll, for example -
function WebForm_PostBackOptions(eventTarget, eventArgument, validation,
validationGroup, actionUrl, trackFocus, clientSubmit)
My C# code behind already has "using System.Web;", and I tried adding "<%@
Import Namespace="System.Web" %>" to the 2.0 .aspx file, but it did not help
with
this issue.

Is there a configuration step I am missing as part of the "port" to 2.0?
 
Reply With Quote
 
 
 
 
Josh Twist
Guest
Posts: n/a
 
      01-10-2006
I had a similar problem and it was a HttpModule that prevented ASP.NET
from serving the "WebResource.axd" file (ASP.NET 2.0 uses this to
deliver scripts, this is different to ASP.NET 1.1).

Could this be your problem? Maybe try temporarily removing any modules
and see if it goes away.

Josh
http://www.thejoyofcode.com/

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      01-11-2006
Josh -
Thanks for your reply.

You said it might be that an HttpModule prevented ASP.NET from serving the
"WebResource.axd" file.

I am not at all sure what that means. Can you say a few more words about
what I might check to see if it is blocked. A log file somewhere?

"Josh Twist" wrote:

> I had a similar problem and it was a HttpModule that prevented ASP.NET
> from serving the "WebResource.axd" file (ASP.NET 2.0 uses this to
> deliver scripts, this is different to ASP.NET 1.1).
>
> Could this be your problem? Maybe try temporarily removing any modules
> and see if it goes away.
>
> Josh
> http://www.thejoyofcode.com/
>
>

 
Reply With Quote
 
Josh Twist
Guest
Posts: n/a
 
      01-11-2006
Most of the JavaScript functions used by ASP.NET are served by a new
'page' called WebResource.axd. Can you see a link to this in your
source, would look something like:

<script src="WebResource.axd...

I had a HttpModule that intercepted all requests to my service to
rewrite urls (e.g. http://mydomain.com/showcategory.aspx?cat=taps to
http://mydomain.com/taps). It turned out that this was stopping the axd
from sending the script down and I got a heap of XXX is undefined
errors.

Josh

 
Reply With Quote
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      01-11-2006
Josh,
Thanks again for hanging with me!

There is no reference to WebResource.axd anywhere in my "solution" directory
(C:\Inetpub\wwwroot\poc_web\).
However, under C:\WINNT\Microsoft.NET\Framework\v2.0.50727, in "web.config"
(which I have not modified directly), there is a section that starts
<httpHandlers>
<add path="trace.axd" verb="*"
type="System.Web.Handlers.TraceHandler" validate="True" />
<add path="WebResource.axd" verb="GET"
type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />
<add path="*.axd" verb="*" type="System.Web.HttpNotFoundHandler"
validate="True" />

etc....

Does that look OK? Is there some other configuration change I need to make,
or is there anything to look at while debugging?



"Josh Twist" wrote:

> Most of the JavaScript functions used by ASP.NET are served by a new
> 'page' called WebResource.axd. Can you see a link to this in your
> source, would look something like:
>
> <script src="WebResource.axd...
>
> I had a HttpModule that intercepted all requests to my service to
> rewrite urls (e.g. http://mydomain.com/showcategory.aspx?cat=taps to
> http://mydomain.com/taps). It turned out that this was stopping the axd
> from sending the script down and I got a heap of XXX is undefined
> errors.
>
> Josh
>
>

 
Reply With Quote
 
Josh Twist
Guest
Posts: n/a
 
      01-11-2006
Don't change that - that's supposed to be there. That's the bit that
makes sure WebResource.axd works properly

I suspect you'd know if you were using HttpModules, so this isn't your
problem. To be sure you can check your web.config file and see if there
are any httpModules configured. They'd be inside a <httpModules> node
somewhere under <system.web>.

However, I mean the web.config in your application, not the one in the
the folder you mention above.

Josh

 
Reply With Quote
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      01-11-2006
Josh -
I don't have any httpModules set up in the application-level web.config file.

Any other ideas?

"Josh Twist" wrote:

> Don't change that - that's supposed to be there. That's the bit that
> makes sure WebResource.axd works properly
>
> I suspect you'd know if you were using HttpModules, so this isn't your
> problem. To be sure you can check your web.config file and see if there
> are any httpModules configured. They'd be inside a <httpModules> node
> somewhere under <system.web>.
>
> However, I mean the web.config in your application, not the one in the
> the folder you mention above.
>
> Josh
>
>

 
Reply With Quote
 
Josh Twist
Guest
Posts: n/a
 
      01-11-2006
Hmmm, not sure...

Let's make sure it is something to do with your WebResource.axd file.
Have a look in your src, you should have a line that looks something
like this (the random characters will be different)

<script
src="/WebResource.axd?d=3v2Q4FZSi09ZwjYwg-vpMg2&amp;t=632674154005468750"
type="text/javascript"></script>

Grab the src path and try and view the file in your browser, i.e. goto
http://localhoast/MyApplication/WebR...74154005468750


(again your random chars will be different)

You will probably need to save the file and view it notepad. If
everything goes OK you should see a file full of lovely javascript...
if not then something is wrong... let me know how you get on.

You could also use ieHTTPHeaders to make sure the file is being
requested and sent back with a normal 200 response code. I wrote an
article about how to use ieHTTPHeaders here:
http://www.thejoyofcode.com/Better_u...TPHeaders.aspx

Hope that helps

Josh

 
Reply With Quote
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      01-12-2006
Josh,
Thanks for hanging with me.
Here is the entire server-generated file for the page in 2.0.
Notice there is no reference to WebResource.axd at all!

-----start file-----

<html><body>
<form id="frmTasks" name="frmTasks" method="post"
action="poc_web_form1.aspx?__ufps=740275">
<input type="hidden" name="__VIEWSTATE"
value="aDxfX1A7QDxmcm1UYXNrczvpobPnlrTvuZngo4gsMjs +Oz5tQovZRH9n2Sgf16Bh56ffmAdj3w==">
<input type="hidden" name="__EVENTTARGET" value="">
<input type="hidden" name="__EVENTARGUMENT" value="">
<script language=javascript><!--
function __doPostBack(target, argument){
var theform = document.frmTasks
theform.__EVENTTARGET.value = target
theform.__EVENTARGUMENT.value = argument
theform.submit()
}
// -->
</script>
<TABLE id="tblMyTasks" cellSpacing="1" cellPadding="1" width="300" border="0">
<TR><TD><IMG alt="Sea State 1" src="ss1_logo.png"></TD></TR>
<TR>
<TD>Task start:</TD>
<TD>Patient:</TD>
<TD>Task:</TD></TR>
<font size="-1">
<TR>
<TD><a id="olstTask__ctl1_lbnStart" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl1:lbnStart','')} ">10/24 9:00</a></TD>
<TD><a id="olstTask__ctl1_lbnPatient" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl1:lbnPatient','')} ">Lee, Terry</a></TD>
<TD><a id="olstTask__ctl1_lbnTask" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl1:lbnTask','')} ">medicate patient</a></TD></TR>
<TR bgcolor="#ccffcc">
<TD><a id="olstTask__ctl2_lbnStart_alt" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl2:lbnStart_alt','')} ">10/24 9:20</a></TD>
<TD><a id="olstTask__ctl2_lbnPatient_alt" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl2:lbnPatient_alt','')} ">Sahu, Subakanta</a></TD>
<TD><a id="olstTask__ctl2_lbnTask_alt" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl2:lbnTask_alt','')} ">medicate
patient</a></TD></TR>
<TR>
<TD><a id="olstTask__ctl3_lbnStart" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl3:lbnStart','')} ">10/24 9:30</a></TD>
<TD><a id="olstTask__ctl3_lbnPatient" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl3:lbnPatient','')} ">Sahu, Subakanta</a></TD>
<TD><a id="olstTask__ctl3_lbnTask" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl3:lbnTask','')} ">medicate patient</a></TD></TR>
<TR bgcolor="#ccffcc">
<TD><a id="olstTask__ctl4_lbnStart_alt" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl4:lbnStart_alt','')} ">10/24 10:00</a></TD>
<TD><a id="olstTask__ctl4_lbnPatient_alt" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl4:lbnPatient_alt','')} ">Bar, Dale</a></TD>
<TD><a id="olstTask__ctl4_lbnTask_alt" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl4:lbnTask_alt','')} ">medicate
patient</a></TD></TR>
<TR>
<TD><a id="olstTask__ctl5_lbnStart" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl5:lbnStart','')} ">10/24 10:10</a></TD>
<TD><a id="olstTask__ctl5_lbnPatient" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl5:lbnPatient','')} ">Bar, Dale</a></TD>
<TD><a id="olstTask__ctl5_lbnTask" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('olstTask:_ctl5:lbnTask','')} ">medicate patient</a></TD></TR>
</TABLE>
<font size="+0"><a href="javascript:__doPostBack('frmTasks','2')"
>Next</a></font></font></form></body></html>


-----end file-----

"Josh Twist" wrote:

> Hmmm, not sure...
>
> Let's make sure it is something to do with your WebResource.axd file.
> Have a look in your src, you should have a line that looks something
> like this (the random characters will be different)
>
> <script
> src="/WebResource.axd?d=3v2Q4FZSi09ZwjYwg-vpMg2&t=632674154005468750"
> type="text/javascript"></script>
>
> Grab the src path and try and view the file in your browser, i.e. goto
> http://localhoast/MyApplication/WebR...74154005468750
>
>
> (again your random chars will be different)
>
> You will probably need to save the file and view it notepad. If
> everything goes OK you should see a file full of lovely javascript...
> if not then something is wrong... let me know how you get on.
>
> You could also use ieHTTPHeaders to make sure the file is being
> requested and sent back with a normal 200 response code. I wrote an
> article about how to use ieHTTPHeaders here:
> http://www.thejoyofcode.com/Better_u...TPHeaders.aspx
>
> Hope that helps
>
> Josh
>
>

 
Reply With Quote
 
Josh Twist
Guest
Posts: n/a
 
      01-12-2006
Hi Rich,

The source you've just sent doesn't contain any Javascript errors? I
just c&p'd it into a HTML file and viewed it in my browser, worked a
treat??

Josh

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WebForm_PostBackOptions Error Brad ASP .Net 5 08-21-2007 04:49 PM
STL: assistance with error - class undefine type Alden Pierre C++ 7 05-20-2006 06:21 AM
WebForm_PostBackOptions javascript Error Corey ASP .Net Web Services 3 12-01-2005 01:52 AM
WebForm_PostBackOptions javascript Error Corey ASP General 2 03-20-2005 10:47 AM
WebForm_PostBackOptions javascript Error Corey ASP .Net 2 03-20-2005 10:47 AM



Advertisments