Wednesday, 15 April 2015

c# - Basic MVC (button to send e-mail) - ActionLink? -



c# - Basic MVC (button to send e-mail) - ActionLink? -

i have 'mail server configuration' kind of view. on view 2 buttons:

[some form fields] <input class="button" type="submit" value="@t("save")" /> <input class="button" type="submit" value="@t("send test email")" />

the first button calls off controller , returns same view validation/success messages (this form):

[httppost] public actionresult index(mailserversettingsviewmodel viewmodel) { ...

that works brilliantly, 'send test email' button same.

assuming don't want come away page (i.e. load different view), want phone call off controller send test e-mail, 'proper' way utilize actionlink helper? other controller can homecoming same form view? or can somehow utilize same controller determine button pressed decide whether validate view model or phone call off service/class/whatever send test e-mail , responding appropriately?

you can tell way i'm asking come webforms background , it's still case of me getting used what's mvc.

what i've tried

for now, i'm calling off other controller asynchronously ajax. works well, , appropriate, won't case want know how i'd accomplish above other scenarios.

if don't want ajax can start thread send email in controller.

@html.actionlink("send test email", "actionname", "controllername", new { mailserversettingsviewmodel }, new { @class = "button" })

c# asp.net-mvc

No comments:

Post a Comment