views:

99

answers:

1

Hi, my first question here.. :)

Let's begin with the code...

my page is

<form id="form1" runat="server">

<% using (Ajax.BeginForm(null)){%>
               <%=Html.DropDownList("DdlScelta",MVC.Models.SelectLists.ConventionIdsSelectList, "Select by this list")%>

            <%=Ajax.ActionLink("Show the Data", "SetData", new AjaxOptions { UpdateTargetId = "msg" })%>

            <span id="msg"></span>
</form>

and this is my controller method

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SetData(FormCollection form1)
{
//form1["DdlScelta"] etc
}

I've also tried with a better way like

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SetData(string DdlScelta)
{
//not important code
}

but NOTHING to do, as soon one of the 2 actionResult is catched, I have a null value..

Thank you to any who can help me :)

A: 

You have to submit the form

 <input type="submit" value="Somevalue" />

and have the form like this

Ajax.BeginForm("actionName", "controllerName", ajaxOptions)

Something like this

<% using (Ajax.BeginForm("actionName", "controllerName", ajaxOptions))

{%>

//form stuff

<input type="submit" value="Somevalue" />

  <% } %>
San
yeah, in this way everything works, I just wanted to do it with the ActionLink, so, any suggest on why the formcollection/string aren't populated?
Luca Trazzi
ActionLinks dont post the form in which they are present, they just do a get on the href you provide.
San