PowerWEB LiveControls for ASP.NET
LiveImage Class
Members  Example  See Also  Send comments on this topic.
Dart.LiveControls Namespace : LiveImage Class



Displays an image on a Web page.

Syntax

Visual Basic (Declaration) 
<LicenseProviderAttribute(System.ComponentModel.LicenseProvider)>
Public Class LiveImage 
   Inherits System.Web.UI.WebControls.Image
   Implements ILiveControl 
Visual Basic (Usage)Copy Code
Dim instance As LiveImage
C# 
[LicenseProviderAttribute(System.ComponentModel.LicenseProvider)]
public class LiveImage : System.Web.UI.WebControls.Image, ILiveControl  
C++/CLI 
[LicenseProviderAttribute(System.ComponentModel.LicenseProvider)]
public ref class LiveImage : public System.Web.UI.WebControls.Image, ILiveControl  

Example

The following example demonstrates adding items to a Live List control from a database, as well as updating a LiveImage control.
Visual BasicCopy Code
'In this example, items are added to a Live List control from a database
'The items are images to be displayed in a LiveImage
'When one of the items is selected, the corresponding image is displayed
'LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList

Private Sub LiveButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveButton1.Click
    'Make sure that System.Data.OleDb is used

    'Get Items from a Database "images.mdb" in the folder "database"
    'The table is called "Table1" and the column with the filenames is "filename"
    Dim connection As New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("database/images.mdb"))
    Dim sql As String = "SELECT filename FROM Table1"
    Dim adapter As New OleDbDataAdapter(sql, connection)
    Dim dataSet As New DataSet("imagesDataSet")
    adapter.Fill(DataSet, "images")

    'Bind the database to the Live List
    LiveList1.DataSource = DataSet
    LiveList1.DataMember = "images"
    LiveList1.DataTextField = "filename"
    LiveList1.DataBind()

    'Set a starting image, and show it by executing the SelectedIndexChanged event handler
    LiveList1.SelectedIndex = 0
    LiveList1_SelectedIndexChanged(Me, Nothing)
End Sub

Private Sub LiveList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles     LiveList1.SelectedIndexChanged
    'The Live List has been populated with some image filenames
    'When a new item is selected in the list, the new image is displayed
    LiveImage1.AlternateText = "Could not display selected image."
    LiveImage1.ImageUrl = "images/" + LiveList1.SelectedItem.Text
End Sub
C#Copy Code
//In this example, items are added to a Live List control from a database
//The items are images to be displayed in a LiveImage
//When one of the items is selected, the corresponding image is displayed
//LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList

private void LiveButton1_Click(object sender, System.EventArgs e)
{
	//Make sure that System.Data.OleDb is used

	//Get Items from a Database "images.mdb" in the folder "database"
	//The table is called "Table1" and the column with the filenames is "filename"
	OleDbConnection connection = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("database/images.mdb"));
	string sql = "SELECT filename FROM Table1";
	OleDbDataAdapter adapter = new OleDbDataAdapter(sql, connection);
	DataSet dataSet = new DataSet("imagesDataSet");
	adapter.Fill(dataSet, "images");
			
	//Bind the database to the Live List
	LiveList1.DataSource = dataSet;
	LiveList1.DataMember = "images";
	LiveList1.DataTextField = "filename";
	LiveList1.DataBind();

	//Set a starting image, and show it by executing the SelectedIndexChanged event handler
	LiveList1.SelectedIndex = 0;
	LiveList1_SelectedIndexChanged(this, null);
}

private void LiveList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
	//The Live List has been populated with some image filenames
	//When a new item is selected in the list, the new image is displayed
	LiveImage1.AlternateText = "Could not display selected image.";
	LiveImage1.ImageUrl = "images/" + LiveList1.SelectedItem.Text;
}

Remarks

This member is functionally equivalent to System.Web.UI.WebControls.ImageClass.

Inheritance Hierarchy

System.Object
   System.Web.UI.Control
      System.Web.UI.WebControls.WebControl
         System.Web.UI.WebControls.Image
            Dart.LiveControls.LiveImage

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 4.0.2
© 2012 Dart Communications. All Rights Reserved.