Welsh King
Welsh King

Reputation: 3238

Cant see server Audio Tag in codebehind

I have

    <audio runat="server" id="audioMessageToPlay" src="" controls="controls"/>

in a user control, i want to manipulate the src tag in code behind, but when i get there the control

    audioMessageToPlay.src 

isnt there ?

I cant even do

    audioMessageToPlay.Attributes.Add("src", "mymusic.mp3")

Any ideas on how to get it, im currently updating to SP1 maybe that will help ?

Upvotes: 1

Views: 786

Answers (1)

Pilgerstorfer Franz
Pilgerstorfer Franz

Reputation: 8359

I am using VS2010 SP1 and the code below works fine for me. Unfortunatelly audioMessageToPlay.src is not working.

protected void Page_Load(object sender, EventArgs e)
{
    audioMessageToPlay.Attributes.Add("src", "media/keineZeit.mp3");
}

Tried the code in VS2008 and worked there, too. Again audioMessageToPlay.src is not working. Finally checked VS2012 - Attributes.Add(.., ..) and src are working!!

VS2012 code behind audio tag

Sidenote: None of my versions properly shows the audio tag, while in designMode.

Upvotes: 2

Related Questions