Click here to Skip to main content
15,890,579 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: I am still struggling to find a fix for this. Can some guru please help? Pin
jkirkerx5-Dec-14 13:47
professionaljkirkerx5-Dec-14 13:47 
GeneralRe: I am still struggling to find a fix for this. Can some guru please help? Pin
samflex5-Dec-14 14:23
samflex5-Dec-14 14:23 
GeneralRe: I am still struggling to find a fix for this. Can some guru please help? Pin
jkirkerx5-Dec-14 16:37
professionaljkirkerx5-Dec-14 16:37 
GeneralRe: I am still struggling to find a fix for this. Can some guru please help? Pin
samflex5-Dec-14 17:52
samflex5-Dec-14 17:52 
GeneralRe: I am still struggling to find a fix for this. Can some guru please help? Pin
jkirkerx5-Dec-14 18:11
professionaljkirkerx5-Dec-14 18:11 
GeneralRe: I am still struggling to find a fix for this. Can some guru please help? Pin
samflex6-Dec-14 3:47
samflex6-Dec-14 3:47 
GeneralRe: I am still struggling to find a fix for this. Can some guru please help? Pin
jkirkerx6-Dec-14 7:53
professionaljkirkerx6-Dec-14 7:53 
GeneralWorking copy of your code. Pin
jkirkerx6-Dec-14 9:00
professionaljkirkerx6-Dec-14 9:00 
[EDIT]

I fixed your code, and now it works.
I don't really code in c#, and can't figure out why I have to click the button twice to populate the blue textbox, the postback results of the client script. Maybe someone else can give me some insight into this.

but like I said, I didn't see any asp.net in your first post, so it really seems like a javascript issue.

In hindsight, it looks you you pasted a bunch of code from the inter webs on to a web form, expecting it to work, without solid knowledge of how java script works, and how to adjust asp.net to it for the postback value to do whatever you need to do with it.

I can tell that you have very little experience with client scripting and asp.net, and could use a little more time and practice on that subject.

Like I said last night, it was just concept code, you were not suppose to copy and paste it into your work. You were suppose to see the difference and type that into your project.

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html>
<script runat="server">
    
    
    protected void bt_search_Click(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            String m_results = txt_results.Text;
            txt_postback.Text = m_results;

        }
    }
</script>


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
 <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>

    <script type="text/javascript">

        var geocoder, location1, location2;

        function initialize() {
            geocoder = new GClientGeocoder();
        }

        function showLocation() {

            var vFlag = true;

            geocoder.getLocations(document.getElementById('txt_address1').value, function (response) {
                if (!response || response.Status.code != 200) {
                    alert('Sorry, we were unable to geocode the first address');
                    vFlag = false;
                }
                else {

                    location1 = { lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address };
                    geocoder.getLocations(document.getElementById('txt_address2').value, function (response) {
                        if (!response || response.Status.code != 200) {
                            alert('Sorry, we were unable to geocode the second address');
                            vFlag = False;
                        }
                        else {
                            
                            location2 = { lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address };
                            calculateDistance();

                        }
                    });
                }
            });            

            return vFlag;
        }

        function calculateDistance() {
            try {

                var glatlng1 = new GLatLng(location1.lat, location1.lon);
                var glatlng2 = new GLatLng(location2.lat, location2.lon);
                var mdistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);

                var mResults = '' +
                'Address 1: ' + location1.address + '\r\n' + 
                'Address 2: ' + location2.address + '\r\n' +
                'Distance: ' + mdistance + ' miles (or ' + mdistance + ' kilometers)';

                document.getElementById('txt_results').value = mResults;

            }
            catch (error) {
                alert(error);
            }
        }

    </script>
  </head>
 
  <body onload="initialize()">
 
    <form runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel ID="up_geoAddress" runat="server" ChildrenAsTriggers="False" ClientIDMode="Static" UpdateMode="Conditional">
            <ContentTemplate>
                <div style="width: 650px; display: block; text-align: left; margin: 6px;">
                    <asp:TextBox ID="txt_address1" runat="server" value="" CssClass="address_input" Style="Width: 80%;" ClientIDMode="Static"></asp:TextBox>
                    <asp:TextBox ID="txt_address2" runat="server" value="" CssClass="address_input" Style="Width: 80%;" ClientIDMode="Static"></asp:TextBox>
                </div>
                <div style="width: 650px; display: block; text-align: left; margin: 6px;">
                    <asp:Button ID="bt_search" runat="server" Text="Search" OnClick="bt_search_Click" style="width: 80%;" OnClientClick="return showLocation();" />
                </div>
                <div style="width: 650px; height: 128px; display: block; text-align: left; line-height: 128px;">
                    <asp:TextBox ID="txt_results" runat="server" style="width: 80%; height: 96px; border: solid 1px rgb(255,0,0);" ClientIDMode="Static" TextMode="MultiLine"></asp:TextBox>
                </div>
                <div style="width: 650px; height: 128px; display: block; text-align: left; line-height: 128px;">
                    <asp:TextBox ID="txt_postback" runat="server" style="width: 80%; height: 96px; border: solid 1px rgb(0,0,255);" ClientIDMode="Static" TextMode="MultiLine"></asp:TextBox>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="bt_search" EventName="Click" />
            </Triggers>
       </asp:UpdatePanel>

    </form>
     
  </body>
</html>


modified 6-Dec-14 18:37pm.

GeneralRe: Working copy of your code. Pin
samflex6-Dec-14 14:47
samflex6-Dec-14 14:47 
GeneralRe: Working copy of your code. Pin
samflex6-Dec-14 16:21
samflex6-Dec-14 16:21 
QuestionAsp.net page with Web Service WITHIN code behind being called Pin
StealthRT4-Dec-14 5:13
StealthRT4-Dec-14 5:13 
QuestionRe: Asp.net page with Web Service WITHIN code behind being called Pin
jkirkerx4-Dec-14 8:55
professionaljkirkerx4-Dec-14 8:55 
SuggestionRe: Asp.net page with Web Service WITHIN code behind being called Pin
ZurdoDev4-Dec-14 10:45
professionalZurdoDev4-Dec-14 10:45 
Question.NET System.OutOfMemoryException in View using DisplayTemplate Pin
G-Alonso30-Nov-14 1:39
G-Alonso30-Nov-14 1:39 
AnswerRe: .NET System.OutOfMemoryException in View using DisplayTemplate Pin
Matt U.4-Dec-14 4:43
Matt U.4-Dec-14 4:43 
QuestionDisplaying javascript values from one page to another using multiview Pin
samflex29-Nov-14 14:10
samflex29-Nov-14 14:10 
AnswerRe: Displaying javascript values from one page to another using multiview Pin
Anurag Gandhi30-Nov-14 22:41
professionalAnurag Gandhi30-Nov-14 22:41 
GeneralRe: Displaying javascript values from one page to another using multiview Pin
samflex1-Dec-14 5:54
samflex1-Dec-14 5:54 
Questioncan anyoen tell me when i use file upload in asp.net.how to rename file with id..its very urgent..plz Pin
Sanju Choudhary S28-Nov-14 2:13
Sanju Choudhary S28-Nov-14 2:13 
AnswerRe: can anyoen tell me when i use file upload in asp.net.how to rename file with id..its very urgent..plz Pin
den2k8828-Nov-14 2:38
professionalden2k8828-Nov-14 2:38 
AnswerRe: can anyoen tell me when i use file upload in asp.net.how to rename file with id..its very urgent..plz Pin
Richard Deeming28-Nov-14 2:43
mveRichard Deeming28-Nov-14 2:43 
GeneralRe: can anyoen tell me when i use file upload in asp.net.how to rename file with id..its very urgent..plz Pin
jaimin851-Dec-14 23:13
jaimin851-Dec-14 23:13 
GeneralRe: can anyoen tell me when i use file upload in asp.net.how to rename file with id..its very urgent..plz Pin
Richard Deeming2-Dec-14 2:23
mveRichard Deeming2-Dec-14 2:23 
QuestionJavascript Scanner recognition Pin
Member 1035398227-Nov-14 22:54
Member 1035398227-Nov-14 22:54 
AnswerRe: Javascript Scanner recognition Pin
ZurdoDev2-Dec-14 3:14
professionalZurdoDev2-Dec-14 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.