如何在asp.net中动态地将视频网址绑定到HTML5视频控件 [英] How to Bind video url to HTML5 video control dynamically in asp.net
本文介绍了如何在asp.net中动态地将视频网址绑定到HTML5视频控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实际上我在我的asp.net网络表单中使用HTML5视频控件。在我的网络表单中我有一个gridview,我放置了一个HTML5视频控件现在我的任务是在行数据绑定动态绑定网址/>
1.)我想在gridview中找到HTML5控件
2.)我想在rowdatabound中动态分配src
是否有可能。以下是我的代码
Actually i am using HTML5 video control in my asp.net web form .here in my my web form i am having a gridview in that i placed a HTML5 video control now my task is to bind url dynamically in row databound
1.) I want to find the HTML5 control in gridview
2.)I want to assign src dynamically in rowdatabound
Is it possible. below is my code
<asp:GridView ID="gvInbox" runat="server" Width="100%" AutoGenerateColumns="False"
onselectedindexchanged="gvInbox_SelectedIndexChanged"
onrowcommand="gvInbox_RowCommand" onrowdatabound="gvInbox_RowDataBound"
AllowPaging="True" PageSize="20"
onpageindexchanging="gvInbox_PageIndexChanging" ShowFooter="True">
<PagerSettings
position="Bottom"
pagebuttoncount="20" Mode="NextPrevious" NextPageText="Next"
PreviousPageText="Previ...."/>
<pagerstyle backcolor="LightBlue"
height="30px"
verticalalign="Bottom" CssClass="cssPager"
horizontalalign="Center"/>
<FooterStyle HorizontalAlign="Center" Height="25px" VerticalAlign="Bottom" BackColor="ActiveBorder" />
<AlternatingRowStyle BackColor="#F6F6F6" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="pnlMsg" runat="server" >
<asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Left"
ImageUrl='<%# Eval("BodyImageUrl").ToString() %>' CssClass="ClsImg" Visible="false" CommandName="EnlImg"
CommandArgument='<%# Eval("BodyImageUrl").ToString() %>' />
<video id="Video" width='300' height='200' controls>
<source src="" type="video/mp4"/>
<p>Fallback code if video isn't supported</p>/
</video>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
推荐答案
你可以添加runat =server属性并像往常一样在GridView的RowDataBound中使用FindControl方法并设置src。
更改+ src + value + source + flowplayer
或者如果源存储在数据库中,那么你可以在MarkupCode本身设置它,比如
You can add runat="server" attribute and use the FindControl method as usual in the RowDataBound of GridView and set the src.
change+src+value+source+flowplayer
Or if the source is stored in the DB then you can set it in the MarkupCode itself like
src="<%# Eval("videosource") %>"
查看此文章可能会有所帮助
使用HTML5和GridView显示音频/视频文件列表 [ ^ ]
这篇关于如何在asp.net中动态地将视频网址绑定到HTML5视频控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文