Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 12:22
    Arthur
    0

    Newbie needing help!

    Hey guys sorry to bother all of you but i was hoping to get some help. I am a complete newbie and i am struggling to find my feet around Umbraco. Been following some tutorials online and i have seem to hit an issue and i can't solve it.

    Tutorial link- https://www.youtube.com/watch?v=e7UeXUtpjck&lc=z134thuxhumayzr3g22mj10zgtq0xnsu1.1486641552014376

    At 11 minutes in when he clicks his submit button it actually functions. When i hit my submit button nothing happens what so ever. The info stays on screen and no send back is sent from the looks of it. It is just a dead button only for show.

    I went through all 4 parts of this series and everything seems fine but when i click the button nothing happens! I would just like this button to work or do anything.

    Going to https://our.umbraco.org/documentation/getting-started/Code/Creating-Forms/

    I find the method here as well but still i can't get my button to work. I'm really hoping someone can help me as this whole Contact Form is useless is this dam button won't work.

    Sorry for the long post. Attached is screenshots of what my coding looks like.

    ContactModel

    ContactForm

    ContactPage

    ContactSurfaceController

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 12:49
    Dennis Adolfi
    1

    Hi Arthur.

    Do you get some type of console error in your browser? (Press F12 and check the console when you click submit)

    Also I think you should have a HttpPost attribute above your HandleFormPost actionresult. Like so:

            [HttpPost]
            public ActionResult HandleFormPost(ContactModel model)
            {
                // Your code here
            }
    
  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 13:09
    Arthur
    0

    Thank you for replying. I added the [HttpPost] and still nothing. I have pressed F12 and i get this error but it automatically appears as i load the site. When i press the button nothing more pops up so i am not sure what i have done wrong

    enter image description here

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 13:14
    Arthur
    0

    With microsoft edge i see no error thou however the button still does nothing

    enter image description here

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 13:20
    Dennis Adolfi
    1

    Hi again Arthur.

    Have you built your solution? Is seems like you have your controllers and models localted in /controllers and /models, which means you need to build you solution to be able to route your new controller.

    Alternatly, move your controllers and models to the /App_Code folder (you may need to create this folder), that way they will compile at runtime.

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 13:24
    Dennis Adolfi
    1

    FYI i wrote the same code as your screendumps in a local solution and thet form works fine for me. So I guess it has do do something with your controllers not beeing compiled correctly.

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 13:38
    Arthur
    0

    Sorry i'm rather useless lol. Any idea how i can compile them correctly? This seems like a fairly easy thing but i just can't get mine to work.

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 13:33
    Arthur
    0

    Thanks for trying to help Dennis!

    I do build the solution (Control + Shift +B) however i notice that if i build it like this my browser can't connect to my localhost so i press the Play symbol which seems to also build the solution but then i can actually connect to it via my browser.

    I created the App_Code folder and moved my models and controllers in there. Built it and when the site opened i got hit with errors.

    enter image description here

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 13:40
    Dennis Adolfi
    1

    That is because now the same route is defined twice.

    1. Move your controllers and models to /App_Code
    2. Make sure they dont still exisit in /Controllers & /Models
    3. Build your solution.
  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 13:44
    Arthur
    0

    Still giving same error.

    First picture shows them in the App_Code folder. Model and controller folders are empty.

    Second picture shows the error when the build is run

    enter image description here

    enter image description here

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 13:41
    Dennis Adolfi
    1

    Dont call yourself useless. Everyone is new in the beginning.

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 13:49
    Dennis Adolfi
    1

    Ok. Rename the controller and your model in App_Code. That way you wont get that VS error and you will get a new route for this controller.

    Ex.

    ContactSurfaceController - rename > ContactFormSurfaceController

    ContactModel - rename > ContactFormModel

    Then you need to make these changes in your views.

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 14:09
    Arthur
    0

    Sorry had to delete previous post as i uploaded the incorrect pics. Still same issue thou. Have i done anything incorrect here?

    enter image description here

    enter image description here

    enter image description here

    enter image description here

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 14:17
    Dennis Adolfi
    1

    I looks like you have another error now? "The type or namespace 'Home' does not exist..". That doesn't seems to be related to this issue.

    Other than that change the namespace for your controller and model to WebApplication1.

    namespace WebApplication1
    {
        public class ContactFormSurfaceController : SurfaceController
        {
            public ActionResult HandleFormPost(ContactFormModel model)
            {
    
            }
        }
    }
    

    And do the same for you model. After that you need to change the namespaces for your model and controller in your view ContactForm.cshtml (as you can see you are currently referencing WebApplication1.Model... and WebApplication1.Controllers...)

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 14:28
    Arthur
    0

    Still giving the exact same error

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 14:33
    Dennis Adolfi
    1

    Which error? The namespace 'Home' doesn't exist?

    Can you show a screendump of your /Views/Home.cshtml file?

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 14:37
    Arthur
    0

    The error of Route names must be unique. Parameter name: name

    He are my Home screen dumps

    enter image description here

    enter image description here

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 14:41
    Dennis Adolfi
    1

    Strange.

    Could you right-click on your controller and model and select properties, then under Build Action make sure it says "Content".

    enter image description here

    Then build you solution.

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 14:47
    Arthur
    0

    So good news is that i no longer get the error message of them not being unique (Yay!) however the button is still doing nothing

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 14:48
    Dennis Adolfi
    1

    Yay!! :)

    Ok, do you get some kind of error in your console when you try to post your form?

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 14:52
    Arthur
    0

    Console still clean. No error messages that i can see. The console in the web browser

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 14:57
    Dennis Adolfi
    1

    Hehe ok, damn! This was a tricky one. :)

    Could you please provide these screendumps:

    ContactForm.cshml

    ContactModel.cs

    ContactForm.cshtml

    ContactPage.cshtml

    ContactFormSurfaceController

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 15:01
    Arthur
    0

    Here are the requested Screen Dumps

    enter image description here

    enter image description here

    enter image description here

    enter image description here

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 15:17
    Dennis Adolfi
    1

    That is strange. Everyting looks fine.

    I've just litteraly copied every line of your code into my own local project and everything works perfect!, the form gets posted when I press submit.

    I see that the actionresult that the form is posting to is just redirecting to the current page, are you sure that no server request happens when you post your form?

    So unless you have some sort of javascript or something blocking the form, I have no idea why this does´nt work for you. I think its really strange that you dont get any Console errors.

    I did the best I could, sorry it was'nt enough..

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 15:41
    Arthur
    1

    The browser sometimes gives me an error and sometimes not. Gave me this now http://localhost:49971/__browserLink/requestData/100e71caf71d4a46a46ff923f64d9c3e?version=2

    Is there no other button i could create that will do what this one was supposed to do?

    Anyway Thank you so much for all your time and effort. Will just have to leave out a contact form from my test site

  • Arthur 19 posts 91 karma points
    Feb 09, 2017 @ 15:48
    Arthur
    0

    Downloaded Firefox to see if it works here and it gave me this error in its console.

    Use of getPreventDefault() is deprecated. Use defaultPrevented instead. browserLink:37:40278

    Sorry to keep bothering but i thought i would just post it just incase it sheds any light

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Feb 09, 2017 @ 15:57
    Dennis Adolfi
    0

    Follow the solution in this link to disable browser link: http://stackoverflow.com/questions/23101265/disable-browser-link-which-toolbar

    This will remove the error.

    However I don't think it will fix the problem with your form not being posted. :(

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies