Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET MVC 2
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 2
This is the forum to discuss the Wrox book Professional ASP.NET MVC 2 by Jon Galloway, Scott Hanselman, Phil Haack, Scott Guthrie, Rob Conery; ISBN: Professional ASP.NET MVC 2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 1st, 2011, 02:12 AM
Registered User
 
Join Date: Dec 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Default p.131 "blur" function not working

When I click my 'Host a Meeting' tab then insert an address into the 'Address' field then tab out, nothing happens.

I currently have to manually insert the Latitude and Longitude >>> save the meeting >>> then click edit in order to have the map actually load the pin.


As per the following paragraph on p.131 I'm supposed to be able to simply "tab out of the 'Address' field" to load the map with the appropriate location:

"When we type in an address, and then tab away, the map will dynamically update to display the location, and our event handler will populate the latitude/longitude textboxes with the location values:"

I've troubleshot this over and over again and can't seem to figure out what the problem is. Please help.
  #2 (permalink)  
Old January 3rd, 2011, 10:41 AM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

Here's what my DinnerForm.ascx looks like. Hope this will help.

Code:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NerdDinner.Models.DinnerFormViewModel>" %>

<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>

<%: Html.ValidationSummary("Please correct the errors and try again.") %>

<% using (Html.BeginForm()) { %>

    <fieldset>
        <div id="mapDiv">    
            <% Html.RenderPartial("Map", Model.Dinner); %>
        </div> 

        <p>
            <%: Html.LabelFor(m => m.Title) %>
            <%: Html.TextBoxFor(m => m.Title) %>
            <%: Html.ValidationMessageFor(m => m.Title, "*") %>
        </p>
        <p>
            <%: Html.LabelFor(m => m.EventDate) %>
            <%: Html.TextBoxFor(m => m.EventDate) %>
            <%: Html.ValidationMessageFor(m => m.EventDate, "*")%>
        </p>
        <p>
            <%: Html.LabelFor(m => m.Description) %>
            <%: Html.TextAreaFor(m => m.Description) %>
            <%: Html.ValidationMessageFor(m => m.Description, "*")%>
        </p>
        <p>
            <%: Html.LabelFor(m => m.Address) %>
            <%: Html.TextBoxFor(m => m.Address) %>
            <%: Html.ValidationMessageFor(m => m.Address, "*") %>
        </p>
        <p>
            <%: Html.LabelFor(m => m.Country) %>
            <%: Html.DropDownListFor(m => m.Country, Model.Countries) %>       
            <%: Html.ValidationMessageFor(m => m.Country, "*") %>
        </p>
        <p>
            <%: Html.LabelFor(m => m.ContactPhone) %>
            <%: Html.TextBoxFor(m => m.ContactPhone) %>
            <%: Html.ValidationMessageFor(m => m.ContactPhone, "*") %>
        </p>
            
        <p>
            <input type="submit" value="Save" />
        </p>



        <p>
            <%: Html.Hidden("Latitude", Model.Dinner.Latitude)%>
            <%: Html.Hidden("Longitude", Model.Dinner.Longitude)%>
        </p>   


        </fieldset>

    <script type="text/javascript">

            $(document).ready(function () {
                $("#Address").blur(function (evt) {
                    $("#Latitude").val("");
                    $("#Longitude").val("");

                    var address = jQuery.trim($("#Address").val());
                    if (address.length < 1)
                        return;

                    NerdDinner.FindAddressOnMap(address);
                });
            });
    
        </script>


<% } %>


<script type="text/javascript">
//<![CDATA[
    $(document).ready(function () {
        NerdDinner.EnableMapMouseClickCallback();

        $("#Dinner_Address").blur(function (evt) {
            //If it's time to look for an address, 
            // clear out the Lat and Lon
            $("#Dinner_Latitude").val("0");
            $("#Dinner_Longitude").val("0");
            var address = jQuery.trim($("#Dinner_Address").val());
            if (address.length < 1)
                return;
            NerdDinner.FindAddressOnMap(address);
        });
    });
//]]>
</script>
The Following User Says Thank You to flyinhawaiian For This Useful Post:
Mr. Bill (January 5th, 2011)
  #3 (permalink)  
Old January 5th, 2011, 02:14 AM
Registered User
 
Join Date: Dec 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you for your input and I apologize for my delay in response. My problem was that the Id's in the generated HTML for my DinnerForm controls were different than what my jQuery code was looking for.

I simply needed to place "Dinner_" in front of the following controls:
  • Address
  • Latitude
  • Longitude
  #4 (permalink)  
Old January 8th, 2011, 07:09 PM
Registered User
 
Join Date: Jan 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Mr. Bill View Post
I simply needed to place "Dinner_" in front of the following controls:
  • Address
  • Latitude
  • Longitude
I don't get it. The jQuery function is looking for "Address". How is it supposed to pick off Dinner_Address?

any help would be much appreciated...

Thanks
  #5 (permalink)  
Old January 9th, 2011, 12:49 AM
Registered User
 
Join Date: Jan 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How is it supposed to pick off Dinner_Address?

Quote:
Originally Posted by shark777 View Post
I don't get it. The jQuery function is looking for "Address". How is it supposed to pick off Dinner_Address?

any help would be much appreciated...

Thanks
never mind - i figured it out
  #6 (permalink)  
Old January 14th, 2011, 12:30 AM
Registered User
 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default hi

nice .. good day




gift ideas husband - Hawaii Movers - unique birthday gifts for men women
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
Need code corrections "get sub or function not defined" error" bluesboytoo Excel VBA 1 October 22nd, 2009 11:12 PM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 01:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM



All times are GMT -4. The time now is 06:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.