Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Sys.ScriptLoadFailedException when switching control visible property from false within partial page render

Reply
Thread Tools

Sys.ScriptLoadFailedException when switching control visible property from false within partial page render

 
 
Andrew Jocelyn
Guest
Posts: n/a
 
      01-27-2009
Hi

I have a web control which can be visible=false on page load. When I do a
postback with in an UpdatePanel (EnablePartialRendering=true) I get the
following error.

Microsoft JScript runtime error: Sys.ScriptLoadFailedException: The script
'DisplayLengthFunctions.js' failed to load. Check for:
Inaccessible path.
Script errors. (IE) Enable 'Display a notification about every script
error' under advanced settings.
Missing call to Sys.Application.notifyScriptLoaded().

The control has a OnPreRender event as follows:

protected override void OnPreRender(EventArgs e)
{
ScriptManager.RegisterClientScriptInclude(
this,
this.GetType(),
"DisplayLengthFunctions",
ResolveClientUrl("~/DisplayLengthFunctions.js"));

ScriptManager.RegisterStartupScript(this, this.GetType(),
string.Format("{0}_DisplayLength", this.UniqueID),
string.Format("DisplayCounter('{0}','{1}_Counter', {2});", _textBox.ClientID,
this.UniqueID, this.MaxLength), true);
}

If I put the above in the OnLoad event I get the same error. If the control
is visible=true on on initial page load then postback works as expected.
What do I need to do to allow the control to work after a postback makes it
visible?

Thanks
Andrew


 
Reply With Quote
 
 
 
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      01-28-2009
Hi Andrew,

I think you can try the following code:

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ScriptManager.RegisterClientScriptInclude(
this,
this.GetType(),
"DisplayLengthFunctions",
ResolveClientUrl("~/DisplayLengthFunctions.js"));

}

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);

ScriptManager.RegisterStartupScript(this, this.GetType(),
string.Format("{0}_DisplayLength", this.UniqueID),
string.Format("DisplayCounter('{0}','{1}_Counter', {2});",
_textBox.ClientID,
this.UniqueID, 2), true);
}

Please have a try and let me know if it works.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
 
Andrew Jocelyn
Guest
Posts: n/a
 
      01-28-2009
Hi Allen

Thanks for your quick response.

Your suggestion does work to a point. If I move the
ScriptManager.RegisterClientScriptInclude to the OnInit event and use the
control directly in a aspx page it works as expected.

If I create a new server control (inheriting CompositeControl) which uses
the first control and use this in the aspx page I get the same error as
before.

Microsoft JScript runtime error: Sys.ScriptLoadFailedException: The script
'DisplayLengthFunctions.js' failed to load. Check for:
Inaccessible path.
Script errors. (IE) Enable 'Display a notification about every script
error' under advanced settings.
Missing call to Sys.Application.notifyScriptLoaded().

The only way I have found to make it work is to then add the same
ScriptManager.RegisterClientScriptInclude to the OnInit event of the new
control which is quite messy.

Any ideas?
Thanks
Andrew



 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      01-29-2009
Hi Andrew,

Thanks for your update. Could you send me a demo that can reproduce this
problem? I'll debug it on my side to find a better solution. My email is
. Please update here after sending the project in case
I missed that email.

BTW, you can also try to set EnablePartialRendering="false" for the
ScriptManager. It's another way to eliminate this error.


Regards,
Allen Chen
Microsoft Online Support

 
Reply With Quote
 
Andrew Jocelyn
Guest
Posts: n/a
 
      01-29-2009
Hi Allen

I tried to recreate the problem this morning and it works fine now. I have
to assume that when I made changes to the code the compiler wasn't getting
the latest version for some reason.

Anyway, your suggestion appears to have solved my problem.

Thanks again
Andrew


 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      01-30-2009
You're welcome Andrew. Have a nice day!

Regards,
Allen Chen
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.
=================================================

 
Reply With Quote
 
Andrew Jocelyn
Guest
Posts: n/a
 
      02-08-2009
Hi Allen

I'm still having problems with this issue. I thought it was fixed but it may
be that the error is obscured when the browser script debugging is disabled.

I've sent you a test project to your email address. To reproduce the error
please do the following:

1. In VS debug mode Open Default.aspx
2. Select the first item in the dropdown, and click insert

You should see the error:
Microsoft JScript runtime error: Sys.ScriptLoadFailedException: The script
'/WebSite1/WebResource.axd?d=VIVtZlXTi1Q0cYaUqsuMvtJoO2HZpcU3 9moCg2hcQqvr4xnysyy43dqxLPOLf7ZkgPswyYS0liAUbiQJJX joCw2&t=633696911894505000'
failed to load. Check for:
Inaccessible path.
Script errors. (IE) Enable 'Display a notification about every script
error' under advanced settings.
Missing call to Sys.Application.notifyScriptLoaded().

3. Click 'Ignore' in the script debugger dialog.
4. the page then loads correctly, with the JS files. Typing in the textarea
box correctly fires the JS functions.

The problem is related to the OnInit event in the TextArea class in the Web
project.

protected override void OnInit(EventArgs e)
{
base.OnInit(e);

ScriptManager.RegisterClientScriptInclude(
this,
this.GetType(),
"DisplayLengthFunctions",
//ResolveClientUrl("~/DisplayLengthFunctions.js"));
this.Page.ClientScript.GetWebResourceUrl(this.GetT ype(),
"Empetus.SCS.Web.UI.WebControls.DisplayLengthFunct ions.js"));
}

I hope you can reproduce the error and suggest a solution.
Thanks
Andrew


 
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
Hide textbox / Make textbox not visible (NOT USING visible property) Jurjen de Groot ASP .Net Web Controls 0 05-19-2008 09:50 AM
When I change field's visible property to false , error occurs . =?Utf-8?B?bWljaGFlbHM=?= ASP .Net 0 06-01-2006 09:19 AM
False positive, false intrusion, false alarm Nick Computer Security 3 04-26-2006 07:40 PM
Why? Partial Class within a Partial class Billy ASP .Net 2 02-01-2006 09:10 AM
Page.Render do not render complete page Lau Lei Cheong ASP .Net 1 05-15-2004 04:10 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57