Is it possible to retrieve a text from a URL or page content by using something like ImageUrl property on the Image Control?
Ex in image:
<asp:Image runat="server" id="Image1" ImageUrl="getImage.aspx?id=2" />
Let's say I have this code on getText.aspx
Imports System.Data
Imports System.Data.SqlClient
Partial Class getText
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim theid As Integer = Request.QueryString("id")
Dim con As New SQLConnection(ConnectionString)
Dim cmd As New SqlCommand("SELECT somefield FROM sometable WHERE id=" & theid)
Dim sda As New SqlDataAdapter(cmd)
Dim ds As New Dataset
sda.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Response.Write( ds.Tables(0).Rows(0).Item("somefield").toString )
For i = 1 To ds.Tables(0).Rows.Count - 1
Response.Write(", " & ds.Tables(0).Rows(i).Item("somefield").toString)
Next
End If
con.Close
End Sub
End Class
and having this database struture on the database,
id somefield
1 student1
2 student2
2 professor1
3 professor2
Assuming that example is running on Label:<asp:Label runat="server" id="Label1 TextUrl="getText.aspx?id=2" />
Output:Label1.Text = "student2, professor1"
I know how to do it on javascript but I don't know how on ASP.NET
It is something like
<script src="getText.js" type="javascript"></script>
I will be using it on Datalist's item template
Please help,
Michael
PS:
Sorry for my poor english.