Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 MVC4
Hi guys
 
I'm new to MVC, so forgive me if this sounds like a silly question:
 
I am building an application using the template that comes with VS2010 and MVC4 using Razor. My problem is buttons... I have tried
<input type="submit" name="value" value="value" />
<button type="submit" name="value" value="value">Test</button>
 
but neither of these do anything. No postback screen refresh or anything.
 
Can anyone tell me what I am missing? It seems like it should be so simple, yet I'm tearing my hair out over this...
 
As far as I am aware, there should be nothing that would disable these.
 
Thanks
Posted 8-Oct-12 10:56am
Unsy575

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

How would it works if you never added any handlers to the button events? Everything you can possibly use is ultimately based on button onclick attribute and JavaScript:
http://www.w3schools.com/jsref/event_onclick.asp[^].
 
—SA
  Permalink  
Comments
Unsy at 8-Oct-12 17:17pm
   
I see. I thought that a submit type button automatically does a postback when clicked with no extra code. I'll look at this. Thanks.
Sergey Alexandrovich Kryukov at 8-Oct-12 18:06pm
   
Actually, this is how the postback on a control works: ASP.NET generates HTML with event handler. If you load such page on client size and see it via "View Page Source", you will see what happens on client side, pure HTML + JavaScript.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 646
1 OriginalGriff 385
2 CPallini 240
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,795
1 Sergey Alexandrovich Kryukov 5,158
2 CPallini 4,740
3 George Jonsson 3,167
4 Gihan Liyanage 2,450


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100