[CLOSED] Razor Get field value from form

  1. #1

    [CLOSED] Razor Get field value from form

    Hi Guys

    Hopefully an easy one to do with referencing I have a Grid panel that I am submiting with two ExtraParams first one is all the data which is all fine.

    Second ExtraParams I want to pass is a hidden value from a numberField from a formpanel on the same page, but I just can seam to get the referencing right.

    I would think that its something like
    App.UserForm.data.KeyID
    but I am not getting anywhere

    Can you guys give me some pointers please?

    Regards
    Last edited by Daniil; Feb 20, 2013 at 12:33 PM. Reason: [CLOSED]
  2. #2
    Hi @OriCoder,

    Maybe just
    App.NumberField1.getValue()
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @OriCoder,

    Maybe just
    App.NumberField1.getValue()
    Hi Daniil

    that would have been too easy. Didn't work firebug tells me that App.KeyId.getValue() is undefined. Below is bit from the view see if this helps put it in context. Must be something simple I am missing.

    Hidden field I am after the value of
    Html.X().Panel()
                                .Title("Group Details")
                                .AutoScroll(true)
                                .Items(
                                 Html.X().FormPanel()
                                 .ID("UserForm")
                                 .Frame(true)
                                 .Url(Url.Action("Submit"))
                                 .DefaultAnchor("100%")
                                 .BodyPadding(6)
                                 .Items(
                                    Html.X().FormPanel()
                                    .Title("User / Group Information")
                                    .MarginSpec("5 5 5 0")
                                    .Items(
                                         Html.X().FieldContainer()
                                        .Layout(LayoutType.HBox)
                                        .LayoutConfig(new HBoxLayoutConfig { Align = HBoxAlign.Stretch })
                                        .Items(
                                        Html.X().NumberField()
                                        .ID("keyID")
                                        .Name("UserGroupId")
                                        .Hidden(true)
                                        .Padding(5),


    Then the direct event I am firing on the save button from a grid panel which sits outside the formpanel

       Html.X().Button()
                                                .Text("Save")
                                                .Icon(Icon.Disk)
                                                .DirectEvents(de =>
                                                {
                                                    de.Click.Url = Url.Action("GroupsHandleChanges");
                                                    de.Click.ExtraParams.Add(new Parameter
                                                    {
                                                        Name = "data",
                                                        Value = "this.up('grid').store.getChangedData({skipIdForNewRecords : false})",
                                                        Mode = ParameterMode.Raw,
                                                        Encode = true
                                                    });
                                                    de.Click.ExtraParams.Add(new Parameter
                                                    {
                                                        Name = "GroupID",
                                                        Value = "App.KeyId.getValue()",
                                                        Mode = ParameterMode.Raw,
                                                        Encode = true
                                                    });
                                                })
  4. #4
    It is lowercase here:
    .ID("keyID")
    but uppercase here:
    Value = "App.KeyId.getValue()"
    The case must be the same.

    Does it help?
  5. #5
    ...damm stupid typo .. :D

    Ok so was getting this far before when it hits the controller the value of "id" is null

    public ActionResult GroupsHandleChanges(StoreDataHandler handler,string id)
    Although firebug tells me in the post data GroupID "1"

    Any thoughts?
  6. #6
    I think the parameters' names must match.
    Name = "GroupID"
    public ActionResult GroupsHandleChanges(StoreDataHandler handler,string GroupID)
  7. #7
    Quote Originally Posted by Daniil View Post
    I think the parameters' names must match.
    Name = "GroupID"
    public ActionResult GroupsHandleChanges(StoreDataHandler handler,string GroupID)
    Sorted ... Think I was just being a bit blonde today.
  8. #8
    Sometimes we all are:)))

Similar Threads

  1. Replies: 0
    Last Post: Oct 22, 2012, 8:36 AM
  2. [MVC + Razor] How to load data on the form?
    By Natalie in forum 2.x Help
    Replies: 4
    Last Post: Sep 18, 2012, 10:24 AM
  3. [CLOSED] [Razor] File upload field - bad response?
    By boris in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 16, 2012, 12:50 PM
  4. [Razor] Populating form values from controller
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 07, 2012, 10:42 AM
  5. Replies: 5
    Last Post: Jul 26, 2011, 12:17 PM

Tags for this Thread

Posting Permissions