Back to Devexpress

ASPxObjectContainer.ObjectUrl Property

aspnet-devexpress-dot-web-dot-aspxobjectcontainer.md

latest3.9 KB
Original Source

ASPxObjectContainer.ObjectUrl Property

Gets or sets the location of the container object.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue("")]
public string ObjectUrl { get; set; }
vb
<DefaultValue("")>
Public Property ObjectUrl As String

Property Value

TypeDefaultDescription
StringString.Empty

A String value that specifies the container object’s location.

|

Example

This demo shows how to display or play back a file in a multimedia format (flash, audio, video) when the file’s filename extension is not specified. In this case, you need to know the file’s MIME type and manually set the ASPxObjectContainer.ObjectType property to a corresponding value (Audio, Video, Flash, or Image).

aspx
<dx:ASPxObjectContainer runat="server" ID="FlashObjectContainer"
    Width="320px"
    Height="284px"
    ObjectUrl="~/Embed.emb?flash=true"
    ObjectType="Flash">
</dx:ASPxObjectContainer>
csharp
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

public class EmbedHttpHandler : IHttpHandler {
    public bool IsReusable {
        get { return false; }
    }

    public void ProcessRequest(HttpContext context) {
        context.Response.Clear();
        context.Response.ContentType = "application/x-shockwave-flash";
        context.Response.BinaryWrite(GetByteFile(context.Server.MapPath("~/Files/FlashClocks.swf")));
        context.Response.End();
    }

    public static byte[] GetByteFile(string filePath) {
        using(Stream fileStream = File.OpenRead(filePath)) {
            byte[] bytes = new byte[fileStream.Length];
            fileStream.Read(bytes, 0, (int)fileStream.Length);
            return bytes;
        }
    }
}
vb
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Web

Public Class EmbedHttpHandler
    Implements IHttpHandler

    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        context.Response.Clear()

        If Not String.IsNullOrEmpty(context.Request.QueryString("flash")) Then
            context.Response.ContentType = "application/x-shockwave-flash"
            context.Response.BinaryWrite(GetByteFile(context.Server.MapPath("~/Files/FlashClocks")))
        End If

        context.Response.End()
    End Sub

    Private Function GetByteFile(ByVal filePath As String) As Byte()
        Dim bytes() As Byte
        Using fileStream As Stream = File.OpenRead(filePath)
            bytes = New Byte(fileStream.Length - 1){}
            For i As Integer = 0 To bytes.Length - 1
                bytes(i) = CByte(fileStream.ReadByte())
            Next i
        End Using

        Return bytes
    End Function
End Class

See Also

ASPxObjectContainer Class

ASPxObjectContainer Members

DevExpress.Web Namespace