textbox supplied route values with javaScript
I've tried the bare method and the T4MVC method but so far both are routing me to the current URL instead of the default path with no arguments for the following action:
public virtual ActionResult Index(byte? location, int? sublocation)
{
}
So when I try
Url.Action("Index","Locations", new {location="", system=""})
if I'm at a location already this method returns the path to where I'm already at instead of the default path with no arguments. As does the following method with T4MVC.
<input type="button" value="Go" style="display:none" onclick="window.location='<%=
Url.Action(MVC.Controller.Index开发者_如何学JAVA())
%>/'+$('input#location').val()+'/'+$('input#sublocation').val()+'/';" />
How can I get the default route with no arguments?
Try Url.Action("Index","Locations")
a 'working' work around:
<input type="button" value="Go" style="display:none" onclick="window.location='<%=
Url.Action("Index","Location")
%>/'.replace(/\/[0-9]+\/[0-9]+\/?/g,'/')
<%-- undecided option here to remove subsequent arguments .replace(/\?.*/,'')--%>
+$('input.location:first').val()+'/'+$('input.subLocation:first').val()+'/';" />
精彩评论