English 中文(简体)
使用 aspx C# 上传后如何自动播放视频@
原标题:How to automatically play video after uploading using aspx C#

我只试过这个简单的上传

默认. aspx :

<AjaxControlToolkit:AsyncFileUpload ID="AsyncFileUpload1" runat="server" CompleteBackColor="White" 
OnUploadedComplete="AsyncFileUpload1_UploadedComplete" OnUploadedFileError="AsyncFileUpload1_UploadedFileError" 
OnClientUploadComplete="Success" OnClientUploadError="Error" /> 
    <br />
<asp:Button runat="server" ID="btnUpload" Text="Upload" Width="84px"/>
<asp:Label ID="Label1" runat="server"></asp:Label>

默认.aspx.cs :

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
    //Fired on the server side when the file successfully uploaded 
    if (AsyncFileUpload1.HasFile)
    {
        AsyncFileUpload1.SaveAs(@"C:Images" + AsyncFileUpload1.FileName);
        Label1.Text = "Received " + AsyncFileUpload1.FileName + " Content Type " + AsyncFileUpload1.PostedFile.ContentType;
    }

}

protected void AsyncFileUpload1_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
    Label1.Text = "Error!!";
    //Fired on the server side when the loaded file is corrupted 

    //Display some error message here 
}
问题回答

独角鲸,

试试下面的代码 如果你还有这个问题...

在 aspx 中 :

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
    <asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" CompleteBackColor="White"
        OnUploadedComplete="AsyncFileUpload1_UploadedComplete" OnUploadedFileError="AsyncFileUpload1_UploadedFileError"
        OnClientUploadComplete="Success" OnClientUploadError="Error" />
</div>
<div>
    <asp:Button runat="server" ID="btnUpload" Text="Upload" Width="84px" OnClick="btnUpload_Click" />
    <asp:Label ID="Label1" runat="server"></asp:Label>
</div>

<div>
 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div>
                <!--STYLE SELECTOR-->
                <div>
                    <h3>
                        VMB Explaining the stage
                    </h3>
                </div>
            </div>
            <!-- MEDIA PLAYER -->
            <sil:MediaPlayer ID="MediaPlayer1" runat="server" Width="600" Height="440" />
        </ContentTemplate>
    </asp:UpdatePanel>
</div>
</form>

也为大会登记

 <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
 <%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="sil" %> // Video Player

以 aspx.cs 计

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
    //Fired on the server side when the file successfully uploaded 
    if (AsyncFileUpload1.HasFile)
    {            
        _strFilePath = AppDomain.CurrentDomain.BaseDirectory + "Uploads\" + AsyncFileUpload1.FileName;
        AsyncFileUpload1.SaveAs(_strFilePath);
        Label1.Text = "Received " + AsyncFileUpload1.FileName + " Content Type " + AsyncFileUpload1.PostedFile.ContentType;
        PlayUploadedFile();
    }

}

private void PlayUploadedFile()
{
    //Here is my Code

    #region Media Player initial settings
    MediaPlayer1.AutoPlay = true;
    MediaPlayer1.ScaleMode = System.Web.UI.SilverlightControls.ScaleMode.Zoom;
    MediaPlayer1.MediaSource = _strFilePath;
    MediaPlayer1.MediaSkinSource = "~/skin/Custom.xaml";
    #endregion

}

protected void AsyncFileUpload1_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
    Label1.Text = "Error!!";
    //Fired on the server side when the loaded file is corrupted 

    //Display some error message here 
}

< a href=" "http://silverlight30.codplex.com/" rel="nofollow" > 视频播放器的视频播放器您必须先查看

您需要引用银光应用程序。Web.dll 和 System.Web.Silverlight.dll

这一切都是。

希望这能彻底解决您的问题 :)





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签