PowerWEB LiveControls for ASP.NET
AlternateText Property
See Also  Send comments on this topic.
Dart.LiveControls Namespace > LiveImage Class : AlternateText Property



Gets or sets the alternate text displayed in the LiveImage control when the image is unavailable. Browsers that support the ToolTips feature display this text as a WebControl.ToolTip.

Syntax

Visual Basic (Declaration) 
Public Overrides Property AlternateText As String
Visual Basic (Usage)Copy Code
Dim instance As LiveImage
Dim value As String
 
instance.AlternateText = value
 
value = instance.AlternateText
C# 
public override string AlternateText {get; set;}
C++/CLI 
public:
property String^ AlternateText {
   String^ get() override;
   void set (    String^ value) override;
}

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.AlternateText.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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