我有这个 .net 页面,其中有一个媒体播放器控件和一个按钮。按钮的功能是调用存储过程。当用户单击按钮时,我需要页面不重新加载和停止视频。
有没有办法做到这一点?
这是代码
看.aspx
<div id="video" runat="server">
<div id="myElement">
Loading...
</div>
</div>
<asp:Button ID="btnWatchlist" runat="server" Text="add to watchlist" onclick="btnWatchlist_Click" />
看.aspx.cs
public partial class Watching : System.Web.UI.Page
{
private int movieId = 0;
protected void Page_Load(object sender, EventArgs e)
{
movieId = Int32.Parse(Request.QueryString["id"]);
Movie movie = MovieAccess.GetMovieDetails(movieId);
startVideo(movie);
}
private void startVideo(Movie movie)
{
string moviePath= "data/videos/"+movie.srcPath;
String script = "<script type='text/javascript'>jwplayer('myElement').setup({file: '" + moviePath + "',image: '43.jpg', \"width\": 800,\"height\": 450,});</script>";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "video", script, false);
}
protected void btnWatchlist_Click(object sender, EventArgs e)
{
MovieAccess.AddWatchlistMovie(movieId, User.Identity.Name);
}
}