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.
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.
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.
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
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.
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.
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.
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...)
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.
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.
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:
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
With microsoft edge i see no error thou however the button still does nothing
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.
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.
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.
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.
That is because now the same route is defined twice.
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
Dont call yourself useless. Everyone is new in the beginning.
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.
Sorry had to delete previous post as i uploaded the incorrect pics. Still same issue thou. Have i done anything incorrect here?
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.
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...)
Still giving the exact same error
Which error? The namespace 'Home' doesn't exist?
Can you show a screendump of your /Views/Home.cshtml file?
The error of Route names must be unique. Parameter name: name
He are my Home screen dumps
Strange.
Could you right-click on your controller and model and select properties, then under Build Action make sure it says "Content".
Then build you solution.
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
Yay!! :)
Ok, do you get some kind of error in your console when you try to post your form?
Console still clean. No error messages that i can see. The console in the web browser
Hehe ok, damn! This was a tricky one. :)
Could you please provide these screendumps:
ContactForm.cshml
ContactModel.cs
ContactForm.cshtml
ContactPage.cshtml
ContactFormSurfaceController
Here are the requested Screen Dumps
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..
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
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
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. :(
is working on a reply...
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.