I’m guessing, something like will get you close.

$('div').click(
$('form[action="SomeAction"]').submit()
)

I hope the action is unique enough I don’t know how mvc renders them now..

From: Greg Low <g...@greglow.com<mailto:g...@greglow.com>>
Reply-To: ozDotNet <ozdotnet@ozdotnet.com<mailto:ozdotnet@ozdotnet.com>>
Date: Sunday, 3 November 2013 10:33 pm
To: ozDotNet <ozdotnet@ozdotnet.com<mailto:ozdotnet@ozdotnet.com>>
Subject: Basic MVC4 question on Form Post

Hi Folks,

I’m still getting my head around MVC4 bit by bit. A quick question if I can:

If I have a form declared:

@using (Html.BeginForm("SomeAction", "SomeController”, FormMethod.Post))
{

}

I would normally just post it by using an input button set to submit. However, 
if I don’t want to use a button but want to make the form post when someone 
clicks on some text in a div contained in the form, how do you do that? Do you 
have to make an onclick for the div execute some java to post the form? If so, 
how would you select the form using jQuery in this case? (If I code forms 
myself, I can give them a name but this Html helper doesn’t seem to have a 
name).

Thanks!  (I’ll be back to databases where I know what I’m doing soon :))

Regards,

Greg

Dr Greg Low
CEO and Principal Mentor
SQL Down Under
SQL Server MVP and Microsoft Regional Director
1300SQLSQL (1300 775 775) office | +61 419201410 mobile│ +61 3 8676 4913 fax
Web: www.sqldownunder.com<http://www.sqldownunder.com/>


Reply via email to