This is working
<embed height="100" width="100" src="WindowsStartup.wav" />
But this is not working
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="4000">
<embed height="100" width="100" src="WindowsStartup.wav" />
</asp:Timer>
How can I fix this ?
The problem source is you're nesting embed
tag inside asp:Timer
server control:
<asp:Timer ID="Timer1" runat="server" Interval="4000">
<%-- This should be placed outside --%>
<embed height="100" width="100" src="WindowsStartup.wav" />
</asp:Timer>
By inspecting rendered HTML output in browser dev tools, I found that the embed
tag nested inside Timer
control completely disappeared, leaving a hidden span
tag with id="Timer1"
where asp:Timer
placed before:
<span id="Timer1" style="visibility:hidden;display:none;"></span>
To fix this issue, put embed
tag outside the control markup, because anything inside server control markup may be reserved for control properties and possibly plain HTML tags inside it not rendered, with exception of certain properties which able to hold HTML templates (eg ItemTemplate
).
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<embed height="100" width="100" src="WindowsStartup.wav" />
<asp:Timer ID="Timer1" runat="server" Interval="4000">
</asp:Timer>
This is rendered output of above markup:
<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', 'form1', [], [], [], 90, '');
//]]>
</script>
<embed height="100" width="100" src="WindowsStartup.wav" />
<span id="Timer1" style="visibility:hidden;display:none;"></span>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.