Gets or sets the location of an image to display in the LiveImage control.
Syntax
Visual Basic (Declaration) | |
---|
Public Overrides Property ImageUrl As String |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As LiveImage
Dim value As String
instance.ImageUrl = value
value = instance.ImageUrl |
C# | |
---|
public override string ImageUrl {get; set;} |
C++/CLI | |
---|
public:
property String^ ImageUrl {
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 Basic | 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 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
Requirements
Target Platforms: Microsoft .NET Framework 2.0
See Also