Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6975873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:25:29+00:00 2026-05-27T17:25:29+00:00

I am struggling with something that I’m not even sure if possible. I have

  • 0

I am struggling with something that I’m not even sure if possible.

I have a typical form page in an .NET MVC 3 Razor project. Within this page is a Google map with a search mechanism. The search is wrapped with a form that calls a JavaScript function to update the map if a location is found.

When I try to use it, the view’s controller handles the request and the controller’s model state is not valid (as the user hasn’t finished with the rest of the form yet). The result is a representation of the page which resets the map (totally the opposite of what I’m after).

Here’s a simplified version of the view:

@model OnlineEventReporting.ViewModels.ReportShortViewData
@{
    Layout = "~/Views/Shared/_LayoutGoogleMap_with_all_js_code.cshtml";
}    
<script type="text/javascript">
    function showAddress(address) { [processing code] }
</script>

 @using (Html.BeginForm("Index", "ShortReport", FormMethod.Post, new { name = "shortForm", id = "shortForm", data_ajax = "false" }))
    {
    @Html.ValidationSummary(true)

    Info for the controller to handle:
        @Html.TextBoxFor(model => model.AddressDetail.Street1, new { @maxlength = "50" })

    <!-- I want this to 'fire' the JavaScript 'showAddress' function and for the controller to ignore it -->

    <form style="text-align:center" action="#" onsubmit="showAddress(this.address.value); return false"> 
        <input type="text" size="20" id="address" name="address" value="North Street, Guildford"  /> 
        <input type="submit" value="Search!" /> 
    </form>

    <div id="map" style="width: 100%; height: 400px; margin-left:20px;"></div> 

    More info for the controller to handle:
        @Html.TextBoxFor(model => model.AddressDetail.Street2, new { @maxlength = "50" })

    }

I realise I have a form within a form here but I’m not how else I could approach this as I need the map and search feature right in the middle of my main form.

Any help would be greatly appreciated.

Many thanks,

Chris.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:25:30+00:00Added an answer on May 27, 2026 at 5:25 pm

    Your code would produce invalid HTML – nested forms are not valid HTML.

    The problem is that the input type="submit" probably causes the topmost form to submit instead of what you expect.

    Why not have a normal button and attach the function to the click event?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am struggling on something that, I am sure, should be easy. I have
I'm struggling with something that I am sure has a very simple method, but
I am seriously struggling on something that has kept me for hours if not
I've been struggling with something at work that I'm not really in the mood
I'm struggling with something that should be fairly easy I think. I have a
I am struggling with something that I think should be easily (ish). I have
I'm struggling with something that should be really easy I think. I have a
I'm struggling with something that I thought is quite simple - to generate documentation
I'm struggling with something that i think would be simple. I know that i've
I'm really struggling with something that should be a simple matter: Showing a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.