We help IT Professionals succeed at work.

Changing the <embed src="" > in asp.net

GLIanimal
GLIanimal asked
on
Medium Priority
601 Views
Last Modified: 2012-06-21
I had this working, but I did not check it into my source control, now it is over written and I can't not seem to remember the solution. I do however know it was not javascript as most of the other suggestions seem to point to. What I have is the below code in an .aspx page. What I need to do is dynamically add the src of the video upon selecting a product to view. Also, I need to make the asp:panel visible, and I am using a hyperlink and can't seem to get that working either, lol. It's Friday so my brain must be on weekend already.

<div id="vidPan">
          <asp:panel id="videoPanel" runat="server" height="500px" width="500px"><TABLE style="WIDTH: 177px"><TBODY><TR><TD style="WIDTH: 647px; HEIGHT: 499px" colSpan=3 rowSpan=3>
          
          <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" showstatusbar="true" enablecontextmenu="false" autostart="false" width="450" height="450" loop="false" src="" runat="server" id="media"/>
          
          </TD></TR><TR></TR><TR></TR></TBODY></TABLE></asp:panel>
          </div>

Open in new window

Comment
Watch Question

Are you using a plain old hyperlink or an asp.net link button?
Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT

Commented:
what if you did an inline call to asp.net

<embed src="'<%getsrc()%>'">

Author

Commented:
I am using a hyperlink currently.

As far as the inline call, never done that before. Do I need to set a public function or something?
Try something like this....
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChangeEmbed.aspx.cs" Inherits="ChangeEmbed" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div id="vidPan">
        <asp:Panel ID="videoPanel" runat="server" Height="500px" Width="500px" Visible="false">
            <table style="width: 177px">
                <tbody>
                    <tr>
                        <td style="width: 647px; height: 499px" colspan="3" rowspan="3">
                            <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
                                name="mediaplayer1" showstatusbar="true" enablecontextmenu="false" autostart="false"
                                width="450" height="450" loop="false" src="" runat="server" id="media" />
                        </td>
                    </tr>
                    <tr>
                    </tr>
                    <tr>
                    </tr>
                </tbody>
            </table>
        </asp:Panel>
        
        <asp:LinkButton ID="MyLink" Text="Click Me" runat="server" 
            onclick="MyLink_Click"></asp:LinkButton>
    </form>
</body>
</html>
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class ChangeEmbed : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    protected void MyLink_Click(object sender, EventArgs e)
    {
        videoPanel.Visible = true;
 
        media.Attributes["src"] = "blah";
    }
}

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Ok, that one part is what I was looking for, the media.Attributes["src"]. However is there a way to do this with the hyperlink? I realize it doesn't have an click event, but curious as to how I did this before.
Well when you click the hyperlink this will go to a page and then on that page you can read the querystring and thne set the src again based on the querystring - the code will be the same kind of thing, you just won't be using a normal event handler that's all.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.