user2826499
user2826499

Reputation: 121

ASP.NET: Call .swf in .aspx page

I'm trying the code below but its not working..

<object width="425" height="344">
  <embed src="C:\Users\fortress\Desktop\AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>

Also tried this. Not working also.

<object width="425" height="344">
  <embed src="~/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>

Problem:

  1. The swf is not displaying.
  2. I saw an error when I open the designer saying that "A control type was not specified or the specified type could not be found." I already import the shockwave-player for flash but still this error appeared..
  3. I want also that the .swf will be fullscreen played in .aspx.

I'm newbie in ASP.net.. SO yeah, please explain also the code if its okay...

Here's the output in client-side:

enter image description here

Here's the whole code for my client-side:

enter image description here

Thanks!

Upvotes: 0

Views: 1373

Answers (2)

Varlain Systems
Varlain Systems

Reputation: 306

You need both <param> movie tag and <embed>. Try this:

<object type="application/x-shockwave-flash" width="425" height="344">
<param name="movie" value="/Styles/Images/AppointmentApp.swf">
  <embed src="/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>

Good luck!

Upvotes: 0

David
David

Reputation: 218828

This isn't ASP.NET, this is HTML. It might be served to the client by an ASP.NET server-side application, but that makes no difference to the client.

As far as HTML goes, your paths are broken. In both cases:

  • C:\Users\fortress\Desktop\AppointmentApp.swf
  • ~/Styles/Images/AppointmentApp.swf

In the first case you're referencing a file system path. This wouldn't work on any client computer which doesn't have that file. If the file is on the web server then no client will be able to access the web server's C: drive. In the second case you're using a server-side relative path with a ~, and no client will be able to make sense of that.

When the page renders, the path needs to reference the file from the client's perspective. Something like this:

  • /Styles/Images/AppointmentApp.swf

Or perhaps:

  • ../../Styles/Images/AppointmentApp.swf

Or whatever the path is from the rendered page to the SWF file.

I'm not 100% sure if this works well for object/embed tags, but you might be able to use the ~ path reference if you make the tag a server-side control. That should just be as easy as adding runat="server" to the tag:

<embed runat="server" src="~/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>

This would indicate to the ASP.NET application that the control needs some server-side processing before it's rendered to the client, and that processing would include evaluating relative paths.

Upvotes: 2

Related Questions