hi
how to display image at image1, from field table alamatgambar1 is ~/photo/1.jpg
thanks
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
function callTampildata() {
var kodesite = document.getElementById('<%= TextBox1.ClientID %>').value; // Ambil nilai dari TextBox1
// Melakukan AJAX call ke WebMethod 'Tampildata'
$.ajax({
type: "POST",
url: "surveyform.aspx/xTampildata", // URL ke WebMethod
data: JSON.stringify({ kodesite: kodesite }), // Parameter yang dikirim
contentType: "application/json; charset=utf-8", // Tipe konten yang dikirim
dataType: "json", // Tipe data yang diterima
success: function(response) {
// Parsing hasil response dan mengisi TextBox lain dengan hasilnya
var result = response.d;
var data = result.split(';');
document.getElementById('<%= TextBox2.ClientID %>').value = data[0].split(':')[1]; // namasite
document.getElementById('<%= TextBox3.ClientID %>').value = data[1].split(':')[1]; // prov
document.getElementById('<%= Image1.ClientID %>').value = data[2].split(':')[1]; // alamatgambar1
},
error: function(xhr, status, error) {
alert("Error: " + error);
}
});
}
</script>
<WebMethod()>
Public Shared Function xTampildata(kodesite As String) As String
Dim result As String = ""
Using koneksi As New SqlConnection(ambilstringkoneksi)
Dim conn As New SqlCommand("[dbo].[caridatasurvei]", koneksi)
conn.CommandType = CommandType.StoredProcedure
conn.Parameters.AddWithValue("@kodesite", kodesite)
conn.Parameters.AddWithValue("@pil", "1")
Try
koneksi.Open()
Dim myreader As SqlDataReader = conn.ExecuteReader(CommandBehavior.CloseConnection)
If myreader.Read() Then
' Menyusun string hasil query
result = "namasite:" & myreader("namasite").ToString() & ";" &
"prov:" & myreader("prov").ToString() & ";" &
"alamatgambar1:" & myreader("alamatgambar1").ToString()
End If
Catch ex As Exception
result = "Error: " & ex.Message
End Try
End Using
Return result