1

Using: vs'12 Razor asp.net MVC4 Internet App Template EF Code First

  • My Actionlink that i am trying to manipulate

    @Html.ActionLink("Download", "ShowOpenAcreageSummaryReport", new { controller = "DataToExcel" }, new { id = "AddData" })
    
  • The script to attempt this

    $('#AddData').click(function (e) {
    
    var optVal = $("#OptionsDrop").val();
    var Xpro = $("#Prospects").val()
    var Xcnty = $("#Countys").val()
    var Xtwn = $("#TownShips").val()
    var Xrng = $("#Ranges").val()
    var Xsct = $("#Sections").val()
    
    
        var href = "/DataToExcel/ShowLPRStandardLeaseReport/" + Xpro + Xcnty + Xtwn + Xrng + Xsct;
        this.href = ""; //clears out old href for reuse
        this.href = href; //changes href value to currently slected dropdown value
    

    }

  • The actionResult to accept these passed values

    public ActionResult ShowLPRStandardLeaseReport(string pro, string cnty, string twn, string rng, string sec)
    

Now i know this works with 1 variable as i have this code running on another page, however it won't work with multiple.

I have also tried adding + "/" + between the Variables, which had no effect on the outcome.

How can i change my code to be able to pass all variables??

3
  • Have you tried with GET parameters such as some-url/?param1=test&param2=test2 ? Also note that this points to the #AddData element in the click handler. If you want to change the current location, use window.location.href = 'someurl'; Commented Sep 24, 2013 at 19:51
  • I just now attempted + Xpro + "&" + "cnty=" + Xcnty + "&" + "twn=" + Xtwn + "&" + "rng=" + Xrng + "&" + "sec=" + Xsct; but without the "?" let me add this Commented Sep 24, 2013 at 19:52
  • OMG ;/ stupid ? , if you could give a short explanation in your answer why that is required that be great and will be accepted thanks. Commented Sep 24, 2013 at 19:55

1 Answer 1

1

Have you tried with GET parameters such as some-url/?param1=test&param2=test2 ? Also note that this points to the #AddData element in the click handler. If you want to change the current location, use window.location.href = 'someurl';

The ? is necessary to indicate the start of the query string parameters.

Also note that you should be encoding the values with encodeURIComponent to make sure that you are producing a valid URL.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the added tip : encodeURIComponent ill use this from now on

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.