Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2005, 02:43 PM
Authorized User
 
Join Date: Jan 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default dinamically showing a .swf file in a popup window

hi, i like to show a .swf file in a popup window that receives on the querystring a variable indicating what .swf to show. i have this inside the body tag of the popup window:
<OBJECT codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
                height="114" width="250" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
                <PARAM NAME="_cx" VALUE="6615">
                <PARAM NAME="_cy" VALUE="3016">
                <PARAM NAME="FlashVars" VALUE="">
                <PARAM NAME="Movie" VALUE="XX.swf">
                <PARAM NAME="Src" VALUE="XX.swf">
                <PARAM NAME="WMode" VALUE="Window">
                <PARAM NAME="Play" VALUE="-1">
                <PARAM NAME="Loop" VALUE="-1">
                <PARAM NAME="Quality" VALUE="High">
                <PARAM NAME="SAlign" VALUE="">
                <PARAM NAME="Menu" VALUE="-1">
                <PARAM NAME="Base" VALUE="">
                <PARAM NAME="AllowScriptAccess" VALUE="always">
                <PARAM NAME="Scale" VALUE="ShowAll">
                <PARAM NAME="DeviceFont" VALUE="0">
                <PARAM NAME="EmbedMovie" VALUE="0">
                <PARAM NAME="BGColor" VALUE="">
                <PARAM NAME="SWRemote" VALUE="">
                <PARAM NAME="MovieData" VALUE="">
                <PARAM NAME="SeamlessTabbing" VALUE="1">
                <embed src="XX.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
                    type="application/x-shockwave-flash" width="250" height="114"> </embed>
            </OBJECT>

What i want to do is to change on the page load the value of the atributes that represent the path of the .swf (the code is in c#)
 i have this on the page load:

int idUnit= Convert.ToInt32(Request.QueryString["id"]);
string strflashpath= Server.MapPath("\\Upload\\")+idUnit+".swf";

"strflashpath" is the path of the .swf i want to show on the popup.

any suggestions? thanks in advance...
 
Old April 26th, 2005, 04:26 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

- Wrap all of the <OBJECT> HTML inside of an asp:literal control.
- Place some kind of token where you want to drop the file name
(Right now you have 'XX.swf' so that could work fine. I like to use something like '%%SWFFILE%%'.)
- In the ASPX codebehind, do this:
   litMyLiteral.Text = litMyLiteral.Text.Replace("XX.swf", strFlashPath)
      or
   litMyLiteral.Text = litMyLiteral.Text.Replace("%%SWFFILE%%", strFlashPath)

You do NOT want to use Server.MapPath because that will return the absolute LOCAL path (i.e. "C:\inetpub\wwwroot\myapplication\myswfs\myswf.swf ") to the browser which will be of no use. Instead, use Page.ResolveUrl("~/myswfs/myswf.swf") which will return the root relative HTTP path to the swf file ("/myapplication/myswfs/myswf.swf").

-Peter
 
Old April 27th, 2005, 09:18 AM
Authorized User
 
Join Date: Jan 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, i wraped the object tag like this:
<asp:Literal ID=litMyLiteral Runat=server>
<OBJECT.....
   ....
   <PARAM NAME="Movie" VALUE="%%SWFFILE%%">
   <PARAM NAME="Src" VALUE="%%SWFFILE%%">
   ....
<embed src="%%SWFFILE%%" ...></embed>
</OBJECT>
</asp:Literal>

and i have this in codebehind:

int idUnit= Convert.ToInt32(Request.QueryString["id"]);
            string strFlashPath= Page.ResolveUrl("\\Upload\\"+idUnit.ToString()+".s wf");
            litMyLiteral.Text = litMyLiteral.Text.Replace("%%SWFFILE%%", strFlashPath);

the problem is that when i request the page, it never goes to codebehind and the html source remains with the token.
the page is called like this:

hlAFP.NavigateUrl="javascript:var w=window.open('PopUpFAd.aspx?id=0','', 'width=250,height=250,scrollbars=no,resizeable=no' );";

i mean, i assign this to a hyperlink control in codebehind in another page, and the link works well, but the page PopUpFAd.aspx never gets into its codebehind...
Page Load
 
Old April 27th, 2005, 09:46 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Where in the codebehind do you have that code?


You probably also want to change this line:

string strFlashPath= Page.ResolveUrl("\\Upload\\"+idUnit.ToString()+".s wf");

to this:

string strFlashPath= Page.ResolveUrl("~/Upload/"+idUnit.ToString()+".swf");

The \ is used for local file references while the / is for web resources (though I don't think it will matter much. The key is using the ~ if you use the /. If you preceed any url with / it tells the browser to look at the web site root. Assuming that you probably are running this application in a virtual directory, the browser will be referencing a bad resource. By adding the ~ you'll get the complete root relative URL for the resource.

-Peter
 
Old April 27th, 2005, 09:48 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I meant to include:

You do not have to use "~/" in the url. You can use just "upload/..." but then you need to make sure this relative reference is correct to the context of the page that is requesting it.

-Peter
 
Old April 27th, 2005, 09:53 AM
Authorized User
 
Join Date: Jan 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi again. now i solved the postback problem. for some reason i do not had this on private void InitializeComponent():
 this.Load += new System.EventHandler(this.Page_Load);

so my logic will never goes into page load eventhandler.
now the token is replaced with the right one, but the .swf doesn't appear on the page. i think it could be something about the size of the .swf and the size of the window in which i like the .swf be shown. ??????

 
Old April 27th, 2005, 10:07 AM
Authorized User
 
Join Date: Jan 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks.., at last the .swf are showing!!!. now, i want to resize it client side. some kind of this i asked in a topic i posted before and you reply telling that with some scripting i can accomplish this
 
Old April 27th, 2005, 10:59 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Yes, like I mentioned before, I don't have any idea if you can read the swf and get the size of it. Presumably, there are flash APIs or something that could read the proprietary SWF format and give you this information. Otherwise, there may be numerous ways you could accomplish this task with some client scripting. Try a javascript and/or DHTML forum for the specifics on doing this.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
XmlHttp in popup window Guy g. Ajax 1 December 12th, 2007 03:56 AM
Popup window from powerpoint jaw1971 Javascript 1 June 8th, 2007 12:29 PM
Centering Popup window & Blur Parent window jkusmanto Javascript How-To 0 May 25th, 2007 03:19 AM
showing a popup window on click widad Classic ASP Basics 4 October 15th, 2004 09:50 AM
popup window sankar Pro VB 6 0 July 29th, 2003 01:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.