Showing posts with label url. Show all posts
Showing posts with label url. Show all posts

Monday, March 26, 2012

Windows Media Player incompatible with AJAX?

Here's an odd one. I have the Windows Media Player imbedded in a page. I have links on the page which fire a javascript to set the player url and start the player. So far so good. Everything works.

Now add the AJAX bits and make the links asp:LinkButtons. I fire the javascript on the OnClientClick method. The <object> tags for the video player are outside of the UpdatePanel so it doesn't get refreshed. Remember, I want to update it with javascript. So when I click a link, the player loads the correct URL, but will not play! I have to press the play button manually to get it to play.

So what is AJAX doing that prohibits WMP from starting the stream? I have tried starting the player with an addtional command (document.Player.controls.play()) and that doesn't work either. Yet as soon as I remove the AJAX bits, it works just fine. Here's my test .aspx page (minus the code behind page. I'm not triggering any server code in this example). Also, the reason I'm using a LinkButton control is because in my real app, the video links are being displayed in a datagrid.

"C#" AutoEventWireup="true" CodeFile="vidTest.aspx.cs" Inherits="VideoLibrary_vidTest" %> 
1<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="vidTest.aspx.cs" Inherits="VideoLibrary_vidTest" %>2<%@dotnet.itags.org. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">4<html xmlns="http://www.w3.org/1999/xhtml">5<head runat="server">6<title>Untitled Page</title>78<script type="text/javascript" language="javascript">9function StartPlayer(filename)10{11document.Player.url = "mms://communitymedical.org/" + filename;12document.Player.controls.play();13}14</script>1516</head>17<body id="link">18<form id="form1" runat="server">19<asp:ScriptManager ID="ScriptManager1" runat="server">20</asp:ScriptManager>21<div>22<object id="Player" height="320" width="320" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">23<param name="autoStart" value="True">24</object>25<br />26<br />27<asp:UpdatePanel ID="UpdatePanel1" runat="server">28<ContentTemplate>29<asp:LinkButton ID="linkButton" runat="server" OnClientClick="javascript:StartPlayer('flex.wmv')">30Click Me</asp:LinkButton>31</ContentTemplate>32</asp:UpdatePanel>33</div>34</form>35</body>36</html>
"text/javascript" language="javascript">function StartPlayer(filename){document.Player.url ="mms://communitymedical.org/" + filename;//document.Player.controls.play();}</script></head><body id="link"><form id="form1" runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><div><object id="Player" height="320" width="320" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"><param name="autoStart" value="True"></object><br /><br /><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:LinkButton ID="linkButton" runat="server" OnClientClick="javascript:StartPlayer('flex.wmv')">Click Me
"text/javascript" language="javascript">11function StartPlayer(filename)12{13document.Player.url ="mms://communitymedical.org/" + filename;14//document.Player.controls.play();15}16</script>1718</head>19<body id="link">20<form id="form1" runat="server">21<asp:ScriptManager ID="ScriptManager1" runat="server">22</asp:ScriptManager>23<div>24<object id="Player" height="320" width="320" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">25<param name="autoStart" value="True">26</object>27<br />28<br />29<asp:UpdatePanel ID="UpdatePanel1" runat="server">30<ContentTemplate>31<asp:LinkButton ID="linkButton" runat="server" OnClientClick="javascript:StartPlayer('flex.wmv')">32Click Me333435363738

the player is compatible, but the onclientclick in an update panel isn't. look at the client script manager to register a script block in the update panel.

-- bruce (sqlwork.com)


The thing is, the script actually fires. The player knows what video it's supposed to play. If I put an alert() command in the script, it will fire the alert. So I know the script is being executed. I just don't understand why the player won't PLAY, when it plays fine without AJAX enabled.

But I'm willing to try workarounds... how do I register a script block in the update panel? Is that different from just using Page.ClientScript.RegisterScriptBlock(...)?

Thanks

D


Got it fixed. That was it. Once I registered the script to the UpdatePanel, the video player worked fine. I can't say that I understand it.... but it works now. Thanks!

Dana

Whiplash:

The thing is, the script actually fires. The player knows what video it's supposed to play. If I put an alert() command in the script, it will fire the alert. So I know the script is being executed. I just don't understand why the player won't PLAY, when it plays fine without AJAX enabled.

But I'm willing to try workarounds... how do I register a script block in the update panel? Is that different from just using Page.ClientScript.RegisterScriptBlock(...)?

Thanks

D

Wednesday, March 21, 2012

Writing New Control - WebResource Url Throwing Exception

Hey Everyone,

I'm having a really hard time with this one. I recently upgraded to lateest control toolkit, and now i can't use my custom controls. I get the dreaded unrecognized tag error.

When I try to load the webresource.axd url for the javascript, I'm getting the following error:

WebResource.axd?d=_IYF6c389WdEZP8BREten0VCyRTYFXUFn9GR9MRXP-aoOJ5cYUZwsxAz4rdBOPaz6CoHQyUbH48-Kn0gv5WhhCj2yI8nUNAt-hz-wRrJAwI76fBROssmxDJplsNW85vw0&t=632907313964152042

Specified argument was out of the range of valid values.
Parameter name: offset

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: offset

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: offset]
System.Web.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count) +3153595
Microsoft.Web.Services.WebResourceCompressionModule.OnPreRequestHandlerExecute(Object sender, EventArgs e) +1103
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


any ideas?For some reason, the Atlas Control Extender template doesn't make the Behavior.js an embedded resource. Change that in the properties pane and rebuild.
yeah, i saw that in the FAQ, and made sure (and double sure) that it was marked as an embedded resource. and it looks like it is, because i am seeing the resource in the source. it's when the browser tries to read the resource that .NET is throwing that funky WebResourceCompressionModule error...
So using a tool like Fiddler, the js file is being sent across?? Hmmm.
I actually saw this yesterday when I was doing some work but (unfortunately) I didn't ever figure it out, mostly because it kind of magically went a way. I think I rebuilt everything clean and it started working.

Wrong URL for Webservice

Hello

I've a Problem with Webservice Calls and/or Scripttags (not sure)
In the default.aspx I've the following Script declaration:

<asp:ScriptManager ID="scriptManager" runat="server" ScriptMode="debug">
<services>
<asp:servicereference path="~/webservices/myWebservice.asmx" />
<services>
<asp:ScriptManager /
Some times the Service is called with this URL: http://www.mySite.com/webservices/myWebservice.asmx/webservices.myWebservice
The extra "/webservices.myWebservice" is wrong and the Page could not be found.

I'm sure the wrong URL is generated from Javascript (in one of the JS-Files from the Framework) when executing the functions in myWebservice or from the generated HTML-Code from the Default.aspx Page (something like <script language="javascript" src="http://pics.10026.com/?src=http://www.mySite.com/webservices/myWebservice.asmx/webservices.myWebservice />)

Any Ideas how to solve this error? Are there any Updates for the AJAX-Framework?

Your webservice is only like thishttp://www.mySite.com/webservices/myWebservice.asmx

there is no need for webservices.myWebservice /

try it


This is the normal way a webservice method is called. There is nothing wrong in it.

The method name is appended to the webservice url

For example, if you are calling a method called method1 on webservice.asmx, the url will look like

http://.../webservice.asmx/method1


But why do I get errors like the following:

Ausnahmeinformationen:
Ausnahmetyp: InvalidOperationException
Ausnahmemeldung:Request format is unrecognized for URL unexpectedly ending in '/webservices.myWebservice'.

Anforderungsinformationen:
Anforderungs-URL:http://www.mySite.ch/webservices/myWebservice.asmx/webservices.myWebservice
Anforderungspfad: /webservices/myWebservice.asmx/webservices.myWebservice

Threadinformationen:
Thread-ID: 1
Stapelüberwachung: bei System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
bei System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
bei System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
bei System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
bei System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
bei System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

If I try to call the webservice directly, I get the same error in Browser.


Check if you have this in the web.config. I have seen this to cause this error

<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>


Thank you for the tipp. That code is not in the web.conf. I'll try if it helps.


I would guess that your web.config is missing these entries:

<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpHandlers>