ASPxObjectContainer.ObjectUrl Property
Gets or sets the location of the container object.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v19.2.dll
Declaration
[DefaultValue("")]
public string ObjectUrl { get; set; }
<DefaultValue("")>
Public Property ObjectUrl As String
Property Value
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).
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;
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="ASPxperience_ObjectContainer_ObjectType_ObjectType" %>
<%@ Register Assembly="DevExpress.Web.v14.2, Version=14.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Object type manual detection</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxObjectContainer runat="server" ID="FlashObjectContainer"
Width="320px"
Height="284px"
ObjectUrl="~/Embed.ashx"
ObjectType="Flash">
</dx:ASPxObjectContainer>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ASPxperience_ObjectContainer_ObjectType_ObjectType : System.Web.UI.Page {
protected void Page_Init(object sender, EventArgs e) {
}
}
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="ASPxperience_ObjectContainer_ObjectType_ObjectType" %>
<%@ Register Assembly="DevExpress.Web.v14.2, Version=14.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Object type manual detection</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxObjectContainer runat="server" ID="FlashObjectContainer"
Width="320px"
Height="284px"
ObjectUrl="~/Embed.emb?flash=true"
ObjectType="Flash">
</dx:ASPxObjectContainer>
</div>
</form>
</body>
</html>
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Partial Public Class ASPxperience_ObjectContainer_ObjectType_ObjectType
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
End Class
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