tags:

views:

73

answers:

1

Hi,

I'm a bit confused and sorry if this question is repeated elsewhere, I did check and it didnt seem to be here yet.

Is there a way, (without use of JavaScript) to get the currently selected item of a DropDownList and say send it off to an ActionLink?

 <%= Html.DropDownList("Elements") %>

 <%=Html.ActionLink("Add Authorization Element", "AddElement", new {elementGuid = ??? }) %>

The bit I am looking for is something to replace:

???

Thanks,

Ric

A: 

Not without JavaScript, no. Of course, it's trivial with JavaScript.

If you want to do both, add JavaScript to the drop down, then put a submit button inside a noscript tag. Users without JavaScript will have to click the button. Users with JavaScript won't see it.

Craig Stuntz
thanks, its what I feared :) my problem is not that users may not use JavaScript, I just wanted to avoid it as much as possible, thanks!! I checked some examples and I think I could hack something up with JavaScript, would you have a nice example that would fit my sample?
Ric Tokyo
In the onchange event, just assign document.location to "<%= Url.Action(...) %>"
Craig Stuntz
Urm, the lt and gt should of course be < and >. I'm never sure what is going to get encoded here.
Craig Stuntz