List box values on postback - asp.net-mvc

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.

Related

Power Automate Desktop Fill Data from excel to website but multi UI ELEMENT

I am a newbie working on power automate desktop and sorry if my english is not good. Currently I am making a flow that will populate the website from my excel. Excel I will have a list of lists I want it to populate in order. But I am having a problem that when I finish filling in the first position, it will show the second position and go on to third , ..... The HTML Input ID also changes in ascending order. So when I do this Flow, it only executes at the top of all my list from excel. Is there a way that can automatically jump the column according to that line UI element. Thank you
enter image description here
Input text will increase like adGroupInfo.1.adcontent and then you fill that one it will show your second and i want to fill data from my excel to that it will be adgroupInfo.2.adcontent
enter image description here
It same all DIV, SPAN ,But different Input ID
enter image description here
enter image description here
For this you will make use of a variable.
Dummy data:
Navigate to the element in the element list.
The click on the 3 dots menu to see the options.
Select Edit
Then scroll down to the enabled selector, this will in most cases be the id of the element on the web page.
replace the value with the name of the variable that will hold the control id value
Then in your loop assign the value of the UI element to the variable you used as the identifier.
Line 7 (red 2)
This should then fill the boxes as required.

Adding multiple dropdown on clicking a link

I have a link which says "add another field". On clicking the link a dropdown should appear on top with let's say 5 custom fields as list in dropdown. Once user selects a field in that dropdown and clicks hyperlink another dropdown should appear below existing dropdown and with only 4 remaining fields as one is already selected.so how to start this?
https://tutorialslink.com/Articles/How-to-add-control-dynamically-in-Aspnet-MVC-using-Javascript/64 . I have tried to use this link which adds text boxes to get started.
I don't have any code expect for the code in above link which is for text box though. Just need an idea of how to do it in asp.net MvC as i cannot move forward now.
Expected results is to do the above requirement, don't have any actual results as of now

Value from dropdown on IconTabBar empty

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.

SmartGWT ComboBoxItem - item in Combo is not marked in the pick list

I'm using ComboBoxItem(com.smartgwt.client.widgets.form.fields.ComboBoxItem). My question is how to force it to mark, hilight selected value in a pick list?
It is demonstrated in the SmartGWT showcase, Combo with a Label "A simple ComboBoxItem" http://www.smartclient.com/smartgwt/showcase/#styled_combobox_category.
'Mouse' item is in the combo, however in the pick list 'Cat' item is selected - not as I would expect - a 'Mouse'.
Thanks in advance,
emph
You can't. ComboBoxItem's PickList object (the drop down list), always moves its cursor (the selection marker) at the top of the list, or the first element that will be selected based on the user's input. If you want the cursor to show the selected value, use the SelectedItem instead, in the same way you use the ComboBoxItem. One drawback with this, is the fact that you can't type and have the auto-complete effect. However, if you type after you open the PickList for the SelectItem, the cursor will move to a matching option.

How do I get all values from a listbox that are not selected in ASP.NET MVC

I have a form that (amongst other things) contains 2 multi-select listboxes. Basically you can add items to the one on the right from the full list of items on the left using some add/remove buttons.
The problem is that I cannot see a way of picking up the contents of the listbox when posting back to the controller.
I have followed this example:
http://ittecture.wordpress.com/2009/04/30/tip-of-the-day-198-asp-net-mvc-listbox-controls/
This works fine if you have actually selected the items in the listbox before posting. That's not really the way I think this UI should behave though.
Hope that makes sense,
Nick
Thanks for the help guys. I forgot to mention that I am populating the selected items listbox with jQuery. Not sure if that was important or not though.
In the end, I fixed it by selecting all items onclick with jQuery before posting. Seemed like the easiest solution.
I don't think a listbox is the control you want for the control on the right. The way a listbox works (by posting the selected item) is not what you're trying to achieve.
You could consider having a grid or even just a div with a number of strings. There is more Javascript/JQuery to be written, but it will provide a nice user experience because no postbacks will be needed until all the work is complete.
You'll need to use JavaScript/JQuery to add and remove items from the div based on the buttons to add and remove.
In addition, for each item that is added on the right, you'll need to add a hidden input field:
<input type="hidden" id="SelectedItems" value="..." />
Set the value to the key or id of the newly added item. If you remove a field from the right control, make sure you remove the associated hidden field.
To handle items on the right that the user has removed, you'll need hidden fields to indicate which have been removed:
<input type="hidden" id="RemovedItems" value="..." />
Then in your controller you can add two parameters to the Action (or add two field to the viewmodel) which will be arrays of strings. This will be set to all of the values in the hidden fields that were added, and all the ones that were removed.
In addition to listbox, have several hidden input fields to hold "currently added" items. The listbox selection will indicate "items to remove" when selected.
OK, clarification. You have left and right listboxes. Left one holds available items, and selected ones are POSTed and then added. Right one holds currently added items, and selected ones are POSTed and then removed from added items.
Now, you also need to hold currently added items. You can do this via bunch of
<input type="hidden" name="currently_added" value="itemid" />
hidden fields.
Yes you can go jQuery but this is an easy way; not every site should be designed to require JavaScript turned on. The above solution works without JavaScript enabled.
Your post from page will give you 3 arrays:
Left side box selected items to add
Right side box selected items to remove
Hidden fields - already added items
You take (3), remove (2) from it, add (1) to it, and display the same page or do whatever you want.

Resources