Click here to Skip to main content
15,941,690 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to enter the values of the textboxes right into an "img src"

ASP.NET
<asp:TextBox ID="TextBox1" Text="40.78" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" Text="-81.5" runat="server"></asp:TextBox>
<img src="http://www.latlong.net/c/?lat=" & <%=TextBox1.ClientID%> & "long=" & <%=TextBox2.ClientID%> & " alt="latlong" />
Posted
Comments
Thanks7872 18-Jun-14 9:15am    
What if the user enters the invalid value in the textbox?

set img as runat=server and better set these values in code behind .
 
Share this answer
 
you could do something like this:
XML
<asp:textbox id="TextBox1" text="40.78" runat="server"></asp:textbox>
    <asp:textbox id="TextBox2" text="-81.5" runat="server"></asp:textbox>    
    <asp:image id="img1" runat="server" imageurl="" />

<asp:button id="Button1" runat="server" text="go" />


on button click
code behind:

VB
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        img1.ImageUrl = "http://www.latlong.net/c/?lat=" + textbox1.text + "long=" + textbox2.text + "alt=latlong"
    End Sub
 
Share this answer
 
v4
im assuming you are geolocating?

you could do something like this:
XML
<asp:textbox id="TextBox1" text="40.78" runat="server" xmlns:asp="#unknown"></asp:textbox>
    <asp:textbox id="TextBox2" text="-81.5" runat="server" xmlns:asp="#unknown"></asp:textbox>    
    <asp:image id="img1" runat="server" imageurl="" xmlns:asp="#unknown" />

<asp:button id="Button1" runat="server" text="go" xmlns:asp="#unknown" />


on button click
code behind:

VB
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        img1.ImageUrl = "http://www.latlong.net/c/?lat=" + textbox1.text + "long=" textbox2.text + "alt=latlong"
    End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900