ASP.net and implementation of dropdownlist - drop-down-menu

I would like to implement a dropdownlist with some listedItems.After that I want for every selected item to be connected to a new aspx page(i.e. if I select meat I want to have a new aspx page that will contain some information about the meat). Does anybody have any ideas? Thanks,
Naim

Set the Value of your ListItem to the URL you want to redirect to when the item is selected. When the user selects the value, simply redirect to that URL.
This can be done in either Javascript or serverside. I'd prefer doing it in javascript to avoid the extra server roundtrip.

Related

Apex - set items values after submit

I have to regions with items on my page. One of them is to edit data, another one is display only. Editable region is hidden on page load and shows when users click on a button. I'd like to pass data between these regions after submit a page. Are computations after submit the only way to do that? I tried with processes after submit, before header etc. but it didn't work.
I'd like to have one pl/sql code to pass data between two regions after submit, how to do such a thing?
Other options include
dynamic action (you'd use Set value)
button's Redirect to page in this application (where you'd redirect to the same page; Link Builder then lets you choose which items will be set to which values)
If you still can't make it work, consider creating sample page on apex.oracle.com; then provide login credentials so that someone might have a look.

Ajax Load Div based on URI (Instead of onClick)

I am converting an old web application. In the legacy version, there is a page which displays some default content when the user navigates to it. There is a link within that page which reloads the page but with a querystring showform=yes which causes a form to be displayed instead of the content.
In the old version, the page was like this:
http://site.com/directory.asp - for the main page with the content
http://site.com/directory.asp?showform=yes - called when the user
clicked the button to show the form.
In the new version of the web app, that same page is set up with ajax, in that there is a div which contains the default content when someone visits http://site.com/directory. There is a button, which, when clicked (from within that page), some ajax is invoked which swaps out the content and displays the form. There is no change in the URI/querystring.
Here is my question - In the legacy version of the web app, there are some other pages which link the user directly to the page with the form (http://site.com/directory.asp?showform=yes) e.g. so they don't need to click the button once the arrive at directory.asp.
Is there a what I can mimimc this behavior based on how I have that page set up now e.g. displaying the form via ajax in a div?)
Initially I thought that perhaps ajax can be triggered based on the presence of a querystring or an anchor in the URI e.g. /directory#form but I am not sure if that is possible.
I would prefer a solution that is not dependent on jQuery, but will consider it if there are no other options.
Thanks in advance for looking, and please let me know if I can further clarify.
Thanks,
Gary
yes you can trigger AJAX call on the basis of a boolean variable which you can set through the query string.
The default value for the boolean variable is false which forces the user to click on the button to refresh the form section.
But when the comes back on the same page the query string will set the boolean variable to true whereby the javascript function containing the AJAX code is invoked from your JSP/ASP or HTML.

How can I change my URL before loading my view?

I have a CodeIgniter webpage containing (i) a list of items and (ii) a form to add a new item or edit the details of a selected item.
To select an item for editing, I have an "edit" anchor tag with a hyperlink ending with ?id=nnn. This results in a GET request that populates the detail fields of my selected item and redisplays the list. My URL now contains site_address/index.php/country?id=151.
When I submit my changes the list is updated correctly but my URL remains unchanged. What do I need to do in my controller to remove "?id=151 after my update was successful?
Thanks for your help.
I'm not sure of everything you are doing, so I'll just answer directly:
in your controller, after you update, you can:
redirect('site_address/index.php/country');
Does that fit what you mean?
Through php there's no way to change URL after request expect redirecting
redirect('controller/method');
and you can success message using session flash message after redirecting, if that what makes you want to reload the view

How to get MVC web grid dropdown column value using javascript or from controller

We have a dropdown list column in ASP.NET MVC 3.0 WebGrid. User will select a item from that list for each row.
When i click on submit I need to capture the selected value for each row.
Can anyone please give me a sample code for doing this from controller.
Thanks in advance
You can make a column with DropDownList control using a html helper:
grid.Column("List", header: "List", format: #<text>#Html.DropDownList("selection", someItems)</text>)
Then put the whole grid in a "form" statement, which refers to "Save" action in your controller, and create that "Save" action method like this:
public ActionResult Save(string[] selection) {
[...]
}
Why don'y you give telerik.mvc grid a try. It's super smooth and handles such scenarios pretty well. Moreover the effort is pretty less in setting it up.
You can download it as a nuget package.
Examples are here http://demos.telerik.com/aspnet-mvc/grid

How to add a new item to a dropdownlist in a create form in MVC 3?

I have a Form to create a new model object and persist it. That form is displayed in a lightbox or popup.
Some fields are dropdownlist showing related info that lives in another table (other model object related to the main model).
What I need to achieve is without leaving the creation form, create a new item of the related type and update the DropDownList in order to continue filling fields and finaly submit the form.
I have done this in winforms but not really sure which is the best approach in MVC 3:
Trigger another popup with a small form?
Use some kind of editable dropdownlist?
Place a small hidden form right next/after the DDL to allow entering the info to create an item in DDL (and to DB also)?
What do you thing is the best option?
Thanks!
There is no editable dropdown list in HTML. There are some toolkits that simulate it, but in general these are clumbsy and really complex. It's a lot easier to stick with basic controls.
You would proably do best to have a small + sign next to the field, and then popup an editing field that inserts the element into the combobox and sends it to the controller via ajax to add to the database.
An alternative to a second pop up is having a toggle add button. When toggled, then show a small area where you can enter the name. Using ajax, save the name, and then refresh your dropdown. This works well if you only have a few attributes to fill in.

Resources