c#asp.net如何使用bootstrap模式将视频源文件名添加到不同的媒体类型中
c# asp.net how to add video source filename to different media type with bootstrap modal
我想使用javascript更新一个全局C#变量。我想我做不到,因为javascript是客户端。我可以通过javascript传递视频的源文件名,但我如何更新模态中的视频源标记?如有任何帮助,我们将不胜感激。
这是我的代码:
观看视频.aspx
<div class="table-responsive has-margin-bottom">
<asp:DataList ID="DataList2" runat="server" RepeatLayout="Table" RepeatDirection="Horizontal" RepeatColumns="3"
Width="100%" OnItemDataBound="DataList2_ItemDataBound">
<ItemTemplate>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"
data-videoname='<%# Eval("title") %>' data-videofile='<%= fileDirectory %><%# Eval("filename") %>' >
<img src='<%= fileDirectory %><%# Eval("filename") %>.png' class="img-responsive" />
<h3><%# Eval("title") %></h3>
</button>
</ItemTemplate>
</asp:DataList>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" >
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel" ></h4>
</div>
<div class="modal-body">
<video id="video1" class="center-block" autoplay="autoplay" controls="controls" width="640" height="480" >
<source src="<%=videoFile %>.mp4" type="video/mp4" />
<source src="<%=videoFile %>.ogv" type="video/ogv" />
<source src="<%=videoFile %>.wmv" type="video/wmv" />
Video is not supported by your browser or computer
</video>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
母版页
$('#myModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var myFilename = button.data('videofile') //videofilename for source
var myTitlename = button.data('videoname')
var modal = $(this)
modal.find('.modal-title').text(myTitlename)
})
这将在单击时将视频src更新为每个按钮的数据视频文件属性中的内容:
<button onclick="$('#video1 source').attr('src', $(this).data('videofile'));" class=...
相关文章:
- 将添加一个相同类型的事件附加或覆盖以前添加的具有相同名称的事件
- WooCommerce的“添加到购物车”按钮旁边的自定义按钮基于产品类型
- 扩展Nashorn-ecma引擎以添加新的运算符和类型
- 使用jscodeshift添加表达式时,错误{..}与类型字符串不匹配
- 如何将类似类型的多个对象添加到本地存储中
- 将Overlay添加到弹出窗口并添加输入类型字段以退出表单
- 在输入类型数字更改时添加复选框
- 如何在面板中添加在两种类型的谷歌图表之间切换的按钮
- "未捕获的类型错误:未定义的不是函数“;当向输入字段添加值时
- 如何在自定义帖子类型中添加自定义字段
- 如何为chart.js(chartjs.org)中的所有图表类型添加标签/图例
- 微风:将项目添加到复杂类型的数组中
- 输入类型文件将文件路径添加到范围
- 如果我添加 pageX 页面 Y 在 IE8 中不起作用<!文档类型 html>.
- 如何为表单提交添加选择器,仅当特定按钮类型导致表单提交时
- 将 JavaScript 添加到 Freeboard 小部件插件时出现类型错误
- Twitter 引导程序提前类型无法添加到动态创建的元素
- 使用JQuery为DOM元素添加类型
- 已添加类型为“…”的消息的未捕获处理程序
- 如果我要在npm模块中添加类型,我怎么能依赖全局类型呢?