也许这听起来很愚蠢,但我真的不知道如何通过<img>
JavaScript 在我的 .aspx 页面中设置代码。
到目前为止我的代码:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Teste.aspx.vb" Inherits="Teste" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
Latitude: <asp:TextBox ID="nr_latitudeTextBox" runat="server" MaxLength="12" /> <br />
Longitude: <asp:TextBox ID="nr_longitudeTextBox" runat="server" MaxLength="12" /><br />
<asp:Button ID="cmb_mapa" runat="server" Text="Mapa" OnClick="cmb_mapa_Click"/><br />
<script language="javascript" type="text/javascript">
function fonte(lat, lon) {
var src = "http://maps.google.com/maps/api/staticmap?center=lat,lon&zoom=8&size=540x280&maptype=roadmap&sensor=false";
testando("http://maps.google.com/maps/api/staticmap?center=lat,lon&zoom=8&size=540x280&maptype=roadmap&sensor=false", 540, 280, "Mapa");
}
function testando(src, width, height, alt) {
var img = document.createElement("img");
img.src = src;
img.width = width;
img.height = height;
img.alt = alt;
document.body.appendChild(img);
}
</script>
<div id="img">
</div>
</asp:Content>
部分类:
Partial Class Teste
Inherits System.Web.UI.Page
Protected Sub cmb_mapa_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmb_mapa.Click
Page.ClientScript.RegisterStartupScript(Me.GetType(), "testando", "testando(" & nr_latitudeTextBox.Text & "," & nr_longitudeTextBox.Text & ");", True)
End Sub
End Class