943,832 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 977
  • ASP.NET RSS
Feb 18th, 2009
0

Working with frames

Expand Post »
I have an application where i need to show 2 frames. the top frame shows 2 windows media players, one that shows the video of a lecture and the other shows the video of images for the same lecture. In the lower frame i want to show all the imagesassociated with the lecture, so that when the user clicks on one image the video chunk associated with that image is shown in the upper frame.
The video main file (that houses the 2 frames is as follows)
c# Syntax (Toggle Plain Text)
  1. private void Page_Load(object sender, System.EventArgs e)
  2. {
  3. // Put user code to initialize the page here
  4. if (!IsPostBack)
  5. {
  6. string flcode = Request.QueryString["f"].ToString().Trim();
  7. string cpcode = Request.QueryString["c"].ToString().Trim();//image code
  8. string cpPath = Request.QueryString["p"].ToString().Trim();//image path
  9. lblflcode.Text = flcode;
  10. lblcpcode.Text = cpcode;
  11. lblcpPath.Text = cpPath;
  12. if (cpcode == "" || cpcode==string.Empty || cpcode==null && cpPath=="" || cpPath==string.Empty || cpPath== null)
  13. {
  14. GetTopFrame();
  15. GetBottomFrame();
  16. }
  17. }
  18. }
  19. public string GetTopFrame()
  20. {
  21. string flcode = lblflcode.Text.ToString().Trim();
  22. string cpcode="";
  23. string cppath ="";
  24. return "<frame name=\"top\" src=\"TopVideoMain.aspx?f="+flcode+"&c="+cpcode+"&p="+cppath+"\">";
  25. }
  26.  
  27. public string GetBottomFrame()
  28. {
  29. string flcode = lblflcode.Text.ToString().Trim();
  30. return "<frame name=\"top\" src=\"BottomVideoMain.aspx?f="+flcode+"\" >";
  31. }
  32.  
  33. TopVideoMain.aspx
  34. public class TopVideoMain : System.Web.UI.Page
  35. {
  36. protected System.Web.UI.WebControls.PlaceHolder ph2;
  37. protected System.Web.UI.WebControls.PlaceHolder ph3;
  38. protected System.Web.UI.WebControls.PlaceHolder ph;
  39. protected System.Web.UI.WebControls.PlaceHolder ph4;
  40. protected System.Web.UI.WebControls.ImageButton img;
  41. protected System.Web.UI.WebControls.Image img1;
  42. private void Page_Load(object sender, System.EventArgs e)
  43. {
  44. if (!IsPostBack)
  45. {
  46. string flcode=Request.QueryString["f"].ToString().Trim();
  47. string cpcode = Request.QueryString["c"].ToString().Trim();//image code
  48. string cpPath = Request.QueryString["p"].ToString().Trim();//image path
  49. if (cpcode == "" || cpcode==string.Empty || cpcode==null && cpPath=="" || cpPath==string.Empty || cpPath== null)
  50. {
  51. CreateMediaPlayerEmbeddedControl(ph,flcode,500,500);// main video
  52. CreateMediaPlayerEmbeddedControlImage(ph2,flcode,500,500);//main image video
  53. }
  54. else
  55. {
  56. CreateMediaPlayerEmbeddedControlbyImage(ph3,flcode,cpcode,cpPath,500,500);//section video
  57. ShowImage(flcode,cpcode,cpPath);
  58. }
  59. }
  60. }
  61.  
  62. private void ShowImage (string flcode, string cpcode, string cpPath)
  63. {
  64. img1.ImageUrl=cpPath;
  65. }
  66.  
  67. private void CreateMediaPlayerEmbeddedControlbyImage(PlaceHolder ph3,string flcode,string cpcode,string cpPath, int width, int height)
  68. {
  69. ph.Visible=false;
  70. ph2.Visible=false;
  71. ph3.Visible=true;
  72. HtmlGenericControl result = new HtmlGenericControl();
  73. ph3.Controls.Add(result);
  74. HtmlGenericControl embed = new HtmlGenericControl();
  75. result.Controls.Add(embed);
  76. string location = Database.GetVideobycpCode(flcode,cpcode);
  77. // Embed tag.
  78. embed.TagName = "embed";
  79. embed.Attributes.Add("type", "application/x-mplayer2");
  80. embed.Attributes.Add("pluginspage", "http://www.microsoft.com/netshow/download/player.htm");
  81. embed.Attributes.Add("name", "mediaPlayer");
  82. embed.Attributes.Add("width", width.ToString());
  83. embed.Attributes.Add("height", height.ToString());
  84. embed.Attributes.Add("AllowChangeDisplaySize", "1");
  85. embed.Attributes.Add("AllowSize", "0");
  86. embed.Attributes.Add("AutoSize", "0");
  87. embed.Attributes.Add("AutoStart", "1");
  88. embed.Attributes.Add("DisplaySize", "4");
  89. embed.Attributes.Add("EnableContextMenu", "0");
  90. embed.Attributes.Add("Enabled", "1");
  91. embed.Attributes.Add("InvokeURLs", "0");
  92. embed.Attributes.Add("ShowCaptioning", "0");
  93. embed.Attributes.Add("ShowStatusBar", "0");
  94. embed.Attributes.Add("ShowControls", "1");
  95. embed.Attributes.Add("WindowlessVideo", "1");
  96. embed.Attributes.Add("uiMode", "None");
  97. embed.Attributes.Add("src", location);
  98. // Object tag
  99. result.TagName = "object";
  100. result.Attributes.Add("classid", "clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95");
  101. result.Attributes.Add("standby", "Loading Microsoft Windows Media Player components...");
  102. result.Attributes.Add("codebase","http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701");
  103. result.Attributes.Add("type", "application/x-oleobject");
  104. result.Attributes.Add("width", width.ToString());
  105. result.Attributes.Add("height", height.ToString());
  106. result.Controls.Add(new LiteralControl("<param name=\"AllowChangeDisplaySize\" value=\"1\"/>"));
  107. result.Controls.Add(new LiteralControl("<param name=\"AllowSize\" value=\"0\"/>"));
  108. result.Controls.Add(new LiteralControl("<param name=\"AutoSize\" value=\"0\"/>"));
  109. result.Controls.Add(new LiteralControl("<param name=\"AutoStart\" value=\"1\"/>"));
  110. result.Controls.Add(new LiteralControl("<param name=\"DisplaySize\" value=\"4\"/>"));
  111. result.Controls.Add(new LiteralControl("<param name=\"EnableContextMenu\" value=\"0\"/>"));
  112. result.Controls.Add(new LiteralControl("<param name=\"Enabled\" value=\"1\"/>"));
  113. result.Controls.Add(new LiteralControl("<param name=\"Filename\" value=\"" + location + "\"/>"));
  114. result.Controls.Add(new LiteralControl("<param name=\"InvokeURLs\" value=\"0\"/>"));
  115. result.Controls.Add(new LiteralControl("<param name=\"ShowCaptioning\" value=\"0\"/>"));
  116. result.Controls.Add(new LiteralControl("<param name=\"ShowStatusBar\" value=\"0\"/>"));
  117. result.Controls.Add(new LiteralControl("<param name=\"ShowControls\" value=\"1\"/>"));
  118. result.Controls.Add(new LiteralControl("<param name=\"WindowlessVideo\" value=\"1\"/>"));
  119. result.Controls.Add(new LiteralControl("<param name=\"uiMode\" value=\"None\"/>")); }
  120.  
  121. private void CreateMediaPlayerEmbeddedControl(PlaceHolder ph, string flcode, int width, int height)
  122. {
  123. HtmlGenericControl result = new HtmlGenericControl();
  124. ph.Controls.Add(result);
  125. HtmlGenericControl embed = new HtmlGenericControl();
  126. result.Controls.Add(embed);
  127. ph.Visible=true;
  128. string filetype ="v";
  129. string location = Database.getLocation(flcode,filetype);
  130. // Embed tag.
  131. embed.TagName = "embed";
  132. embed.Attributes.Add("type", "application/x-mplayer2");
  133. embed.Attributes.Add("pluginspage", "http://www.microsoft.com/netshow/download/player.htm");
  134. embed.Attributes.Add("name", "mediaPlayer");
  135. embed.Attributes.Add("width", width.ToString());
  136. embed.Attributes.Add("height", height.ToString());
  137. embed.Attributes.Add("AllowChangeDisplaySize", "1");
  138. embed.Attributes.Add("AllowSize", "0");
  139. embed.Attributes.Add("AutoSize", "0");
  140. embed.Attributes.Add("AutoStart", "1");
  141. embed.Attributes.Add("DisplaySize", "4");
  142. embed.Attributes.Add("EnableContextMenu", "0");
  143. embed.Attributes.Add("Enabled", "1");
  144. embed.Attributes.Add("InvokeURLs", "0");
  145. embed.Attributes.Add("ShowCaptioning", "0");
  146. embed.Attributes.Add("ShowStatusBar", "0");
  147. embed.Attributes.Add("ShowControls", "1");
  148. embed.Attributes.Add("WindowlessVideo", "1");
  149. embed.Attributes.Add("uiMode", "None");
  150. embed.Attributes.Add("src", location);
  151. // Object tag
  152. result.TagName = "object";
  153. result.Attributes.Add("classid", "clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95");
  154. result.Attributes.Add("standby", "Loading Microsoft Windows Media Player components...");
  155. result.Attributes.Add("codebase","http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701");
  156. result.Attributes.Add("type", "application/x-oleobject");
  157. result.Attributes.Add("width", width.ToString());
  158. result.Attributes.Add("height", height.ToString());
  159. result.Controls.Add(new LiteralControl("<param name=\"AllowChangeDisplaySize\" value=\"1\"/>"));
  160. result.Controls.Add(new LiteralControl("<param name=\"AllowSize\" value=\"0\"/>"));
  161. result.Controls.Add(new LiteralControl("<param name=\"AutoSize\" value=\"0\"/>"));
  162. result.Controls.Add(new LiteralControl("<param name=\"AutoStart\" value=\"1\"/>"));
  163. result.Controls.Add(new LiteralControl("<param name=\"DisplaySize\" value=\"4\"/>"));
  164. result.Controls.Add(new LiteralControl("<param name=\"EnableContextMenu\" value=\"0\"/>"));
  165. result.Controls.Add(new LiteralControl("<param name=\"Enabled\" value=\"1\"/>"));
  166. result.Controls.Add(new LiteralControl("<param name=\"Filename\" value=\"" + location + "\"/>"));
  167. result.Controls.Add(new LiteralControl("<param name=\"InvokeURLs\" value=\"0\"/>"));
  168. result.Controls.Add(new LiteralControl("<param name=\"ShowCaptioning\" value=\"0\"/>"));
  169. result.Controls.Add(new LiteralControl("<param name=\"ShowStatusBar\" value=\"0\"/>"));
  170. result.Controls.Add(new LiteralControl("<param name=\"ShowControls\" value=\"1\"/>"));
  171. result.Controls.Add(new LiteralControl("<param name=\"WindowlessVideo\" value=\"1\"/>"));
  172. result.Controls.Add(new LiteralControl("<param name=\"uiMode\" value=\"None\"/>"));
  173.  
  174. }
  175.  
  176.  
  177. private void CreateMediaPlayerEmbeddedControlImage(PlaceHolder ph2, string flcode, int width, int height)
  178. {
  179. HtmlGenericControl result = new HtmlGenericControl();
  180. ph.Controls.Add(result);
  181. HtmlGenericControl embed = new HtmlGenericControl();
  182. result.Controls.Add(embed);
  183. ph2.Visible=true;
  184. string filetype = "i";
  185. string location = Database.getLocation(flcode,filetype);
  186. // Embed tag.
  187. embed.TagName = "embed";
  188. embed.Attributes.Add("type", "application/x-mplayer2");
  189. embed.Attributes.Add("pluginspage", "http://www.microsoft.com/netshow/download/player.htm");
  190. embed.Attributes.Add("name", "mediaPlayer");
  191. embed.Attributes.Add("width", width.ToString());
  192. embed.Attributes.Add("height", height.ToString());
  193. embed.Attributes.Add("AllowChangeDisplaySize", "1");
  194. embed.Attributes.Add("AllowSize", "0");
  195. embed.Attributes.Add("AutoSize", "0");
  196. embed.Attributes.Add("AutoStart", "1");
  197. embed.Attributes.Add("DisplaySize", "4");
  198. embed.Attributes.Add("EnableContextMenu", "0");
  199. embed.Attributes.Add("Enabled", "1");
  200. embed.Attributes.Add("InvokeURLs", "0");
  201. embed.Attributes.Add("ShowCaptioning", "0");
  202. embed.Attributes.Add("ShowStatusBar", "0");
  203. embed.Attributes.Add("ShowControls", "1");
  204. embed.Attributes.Add("WindowlessVideo", "1");
  205. embed.Attributes.Add("uiMode", "None");
  206. embed.Attributes.Add("src", location);
  207. // Object tag
  208. result.TagName = "object";
  209. result.Attributes.Add("classid", "clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95");
  210. result.Attributes.Add("standby", "Loading Microsoft Windows Media Player components...");
  211. result.Attributes.Add("codebase", "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701");
  212. result.Attributes.Add("type", "application/x-oleobject");
  213. result.Attributes.Add("width", width.ToString());
  214. result.Attributes.Add("height", height.ToString());
  215. result.Controls.Add(new LiteralControl("<param name=\"AllowChangeDisplaySize\" value=\"1\"/>"));
  216. result.Controls.Add(new LiteralControl("<param name=\"AllowSize\" value=\"0\"/>"));
  217. result.Controls.Add(new LiteralControl("<param name=\"AutoSize\" value=\"0\"/>"));
  218. result.Controls.Add(new LiteralControl("<param name=\"AutoStart\" value=\"1\"/>"));
  219. result.Controls.Add(new LiteralControl("<param name=\"DisplaySize\" value=\"4\"/>"));
  220. result.Controls.Add(new LiteralControl("<param name=\"EnableContextMenu\" value=\"0\"/>"));
  221. result.Controls.Add(new LiteralControl("<param name=\"Enabled\" value=\"1\"/>"));
  222. result.Controls.Add(new LiteralControl("<param name=\"Filename\" value=\"" + location + "\"/>"));
  223. result.Controls.Add(new LiteralControl("<param name=\"InvokeURLs\" value=\"0\"/>"));
  224. result.Controls.Add(new LiteralControl("<param name=\"ShowCaptioning\" value=\"0\"/>"));
  225. result.Controls.Add(new LiteralControl("<param name=\"ShowStatusBar\" value=\"0\"/>"));
  226. result.Controls.Add(new LiteralControl("<param name=\"ShowControls\" value=\"1\"/>"));
  227. result.Controls.Add(new LiteralControl("<param name=\"WindowlessVideo\" value=\"1\"/>"));
  228. result.Controls.Add(new LiteralControl("<param name=\"uiMode\" value=\"None\"/>"));
  229. }
  230.  
  231. BottomVideoMain.aspx
  232. public class BottomVideoMain : System.Web.UI.Page
  233. {
  234. protected System.Web.UI.WebControls.DataList dlImages;
  235. protected System.Web.UI.WebControls.Label lblflcode;
  236.  
  237. private void Page_Load(object sender, System.EventArgs e)
  238. {
  239.  
  240. if (!IsPostBack)
  241. {
  242. string flcode=Request.QueryString["f"].ToString().Trim();
  243. lblflcode.Text = flcode.ToString().Trim();
  244. Getimages(flcode);
  245. }
  246. else
  247. {
  248. string flcode = lblflcode.Text.ToString().Trim();
  249. Getimages(flcode);
  250. }
  251. }
  252.  
  253. private void Getimages(string flcode)
  254. {
  255. SqlParameter[] parms = new SqlParameter[]
  256. {
  257. new SqlParameter("@flcode", SqlDbType.Char,4)
  258. };
  259. parms[0].Value = flcode;
  260.  
  261. DataTable dt= Database.ExecuteQuery(Database.ConnString_eCurr, CommandType.StoredProcedure, "ecA_GetImages", parms);
  262. dlImages.DataSource= dt.DefaultView;
  263. dlImages.DataBind();
  264. dt.Clear();
  265. }
  266.  
  267. protected void dlImages_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
  268. {
  269. if(e.Item.ItemType ==ListItemType.Item || e.Item.ItemType ==ListItemType.AlternatingItem || e.Item.ItemType ==ListItemType.SelectedItem)
  270. {
  271. System.Web.UI.WebControls.ImageButton img = (System.Web.UI.WebControls.ImageButton)e.Item.FindControl("ibImages");
  272. string path = img.CommandArgument.ToString().Trim();
  273. img.ImageUrl= path.ToString().Trim();
  274.  
  275. }
  276.  
  277.  
  278. }
  279.  
  280. protected void ibImages_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  281. {
  282. ImageButton ib = (ImageButton)sender;
  283. DataListItem item = (DataListItem)ib.Parent;
  284. string flcode = lblflcode.Text.ToString().Trim();
  285. Label lblcode =(Label)item.FindControl("lblcpcode");
  286. string cpcode=lblcode.Text.ToString().Trim();
  287. Label lblpath = (Label)item.FindControl("lblcpPath");
  288. string cppath = lblpath.Text.ToString().Trim();
  289. Response.Redirect("TopVideoMain.aspx?f="+flcode+"&c="+cpcode+"&p="+cppath);
  290. // Response.Redirect("VideoMain.aspx?f="+flcode+"&c="+cpcode+"&p="+cppath);
  291.  
  292. }

I am able to see the top video frame and the bottom when the videomain page loads, but when i click on an image- The top frame video doesnt stop but a new windows media player get created in the bottom frame and all the images are lost.
I want the upper frame to start playing the video associated with the image selected.
Thank you in advance.
Last edited by peter_budo; Feb 19th, 2009 at 4:06 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
C#Novice is offline Offline
11 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Dynamic page set up
Next Thread in ASP.NET Forum Timeline: not aware of





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC