Value from dropdown on IconTabBar empty - odata

change view (XML) contains IconTabBar with 3 IconTabFilters, which contain input controls (input, combobox, datePicker...). These input controls have pre-filled value from OData model. On the bottom of the view is button "Save". When I click on "Save" button, in my "onSave" function I am reading values from input controls from all IconTabFilters, but only values from the input controls on the first IconTabFilter are filled. Values from the rest of the fields are empty.
When I click on all IconTabFilters (without changing values), click "Save", then I'm getting all values correctly.
Please what I'm doing wrong? Odata model contains all required values, and also IconTabFilters contain all required values. But I can't read them from input controls before clicking on all IconTabFilters.

The Controls on the tabs only get initiated when they have to be displayed. This is done to improve the felt performance of the UI.
Since you are already using model binding, you should take the values out of the model instead of the input fields.

Related

Passing hidden values to dimple chart

I have a page using jqueryMobile that shows a list of checkboxes. When you select a checkbox it adds a set of numbers to a hidden input. You then click a 'submit' button that goes to the dimple page and it reads the hidden values from the previous page but I want to use those hidden values to filter the dimple chart data.
The problem is that when I submit more than one set of numbers e.g. 001, 002 the dimple chart doesn't show any data.
Do I need to convert the hidden values for dimple to recognise them?
Dimple Code to filter:
data = dimple.filterData(dimple.filterData(data, "ProductCode", passedValues), "OwningDepot", "London");
The values getting passed from a hidden input on the previous page are "001","002","003" so I want to pass those values into the 'passedValues' variable.

mvc razor default value on httppost for unselected radiobuttons

i have 2 radio buttons , which are optional, so by default no radio button is selected, if the user wants he can select the radio button. But on postback i should check whether the parameter entered by the user are same as the parameters defined in the application, for security.
There are other fields n the screen which are optional like textboxes, but textboxes are getting passed on httppost even when the user does not enter a value it is being passed as empty, but if user does not select radio button nothing is getting passed on postback, that field is missing in httppost.
Any work around to pass default value for unselected radio button on httppost.
You could place a "default" radio button, already selected, but not visible on your site ("style: display: none;"). That's the way ASP.NET works when you use some Html helpers like #Html.CheckBox(...) for instance: it places an invisible second checkbox with the same name, but containing the false value. It assures that a value will always be posted, even if the user doesn't check it (checkboxes, radio, etc are never sent with the form if they are not checked).

List box values on postback

I am using asp.net mvc. I have used two list box in one of my views.
I transfer desired items from left-hand-side list box to right-side list box.
On a button click, i want to get the list box contents from right side list box.
I don;t get in form collection. Can anyone please suggest how can I get it?
thanks,
kapil
The only values in the list box that are selected will appear in the form collection.
When you transfer to the second list box, I would add a hidden field and add the cvalues into there (with some delimiter between). Upon POST you could split the string value of this hidden value to find contents of right hand list box.
Alternatively, just prior to Submit (intercept with JavaScript), set all values in right hand list box to selected.

How to know which radio button is selected on a view?

I have a created a list view for one of my controller's index action.
I have added a new column "Select This" to this list view, by using the view's source.
The column will contain radio button for each entry in the list. This i have achieved by just placing a radio button control from tool box in the "Select This" column. This i have done in the design of the view and when i run it, i get radio buttons, one for each of the entry. The page also has a link button and i want to call a controller action on this link button click which will receive the index of radio button selected. So if i select 5th radio button, how can receive 5 in the controller action.
How can i do this?
Regards,
kapil
If you used plain HTML, your radio buttons will all have the same name, but different value. You will get one result in the POST, which will contain the selected value.
If you used ASP.net helpers, it's the same, but they will be generated for you: see here: http://msdn.microsoft.com/en-us/library/dd410596.aspx You will pass the same name (first parameter) and different values for each input (second parameter).

ModelState.IsValid for invisible controls

I am working on MVC with C#.
I have 2 radio buttons. On selecting first radio button, a textbox will be shown which allows to enter date values.
<%= Html.TextBox("ReceivedDate")%>
on selecting the second radio button, the textbox gets hidden.
For the first time, when i select first radio button and entered date and clicked Next to navigate to next page and came back to this page again and clicked second radio button and clicked Next to continue and again i came back to this page and without changing any option click continue, its not allowing to navigate and shows an error.
A value is required.
Which means the ModelState validating the hidden controls also.
Please suggest how to control it
Instead of hiding it remove the element from the DOM and reinsert it if the first item is selected again. Another way would be to change the name of the input control to something else (a key not present in your model data) when the first item is not selected.
Validating hidden input types is a good thing, i often use them to synchronize data from complex controls (like a treeview with checkboxes). An input type with a hidden css style doesn't make it not submit with the form it belongs too.

Resources