How to get the value from View page to the controller using button click (direct event) below is my code attached

  1. #1

    How to get the value from View page to the controller using button click (direct event) below is my code attached

    View Page
    ==================
    @Html.X().ResourceManager()
    
    
    
    <div>
    
    Name : @Html.TextBoxFor(model => model.Name, new { @class = "x-form-field", style = "width:300px;" })<br />
    Address : @Html.TextBoxFor(model => model.Address, new { @class = "x-form-field", style = "width:300px;" })<br />
    City : @Html.TextBoxFor(model => model.City, new { @class = "x-form-field", style = "width:300px;" })<br />
    Country : @Html.TextBoxFor(model => model.Country, new { @class = "x-form-field", style = "width:300px;" })<br />
    </div>
    <div>
    @( Html.X().Button() .Text("Submit")
    
    .DirectEvents(de => {
    de.Click.Url = Url.Action("DirectEventSubmit");
    de.Click.EventMask.ShowMask = true;
    })
    )
    </div>
    =======================================
    Controller
    =======================================

    public ActionResult DirectEventSubmit()
    {
    return this.Direct();
    }
    =======================================
    Model
    =======================================
    public class Enquiry
    {
    DbFactory ObjDbfactory;
    protected void InitializeDB()
    {
    ObjDbfactory = new DbFactory(DataBaseType.SQLServer, ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString);
    }
    
    public string Mode { get; set; }
    public string Name { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string Country { get; set; }
    }
    i had tried calling the model in the view page, it displays only the null value, please give me solution, how to get the value passed from the view page to the controller.

    Thanks in advance,
    Suresh G
    Last edited by Daniil; Jun 30, 2014 at 12:51 PM. Reason: Please use [CODE] tags
  2. #2
    Hi @sundarsureshin,

    To send parameters you can use a DirectEvent's ExtraParams.
    de.Click.ExtraParams.Add(new { paramName = "paramValue"});
    public ActionResult DirectEventSubmit(string paramName)
    
    {
        X.Msg.Alert("DirectEventSubmit", paramName).Show();
    
        return this.Direct();
    
    }
    As for submittin a Model, there is an example:
    http://mvc.ext.net/#/Models/FormPanelFor/

Similar Threads

  1. [CLOSED] How can I pass store data on button click direct event
    By jstifel in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Nov 29, 2013, 11:10 AM
  2. Replies: 0
    Last Post: Oct 24, 2013, 2:53 PM
  3. [CLOSED] Load MultiSelectCombobox during button click direct event
    By OSYS_FMS in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 02, 2012, 1:30 PM
  4. Replies: 6
    Last Post: Dec 14, 2011, 5:24 AM
  5. [CLOSED] Make enter key activate button click direct event
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 15, 2010, 6:02 PM

Posting Permissions