Url.Action parameters(string)

This is a part of my jQuery in a view in MVC3.

function GetList(ii, href) {
    var toataSucursala =  $("#ToataSucursala").is(':checked');
    var IdAccessLevel = $("#IdAccessLevel").val();
    var InclusivDescendents = $("#InclusivDescendents").is(':checked');
    var numeAsigurat = $("#NumeAsigurat").val();
    var prenumeAsigurat = $("#PrenumeAsigurat").val();

    //console.log("IdAccessLevel: " + IdAccessLevel);
    //console.log("InclusivDescendents: " + InclusivDescendents);

    if (ii != 0) {
        var s = "@Url.Action("PoliteDeReinnoitGrid", new { ViewBag.User.Id, @expiraInZile = -10, @page = 0})" + "&toatasucursala="+toataSucursala+"&numeAsigurat="+numeAsigurat+"&prenumeAsigurat="+prenumeAsigurat;
        //console.log('URL s: ' + s);
        var joindate = new Date(); 
        //var joindate = $('#DatePicker').datepicker("getDate");

#NumeAsigurat is a textbox.

The problem is, if I write a two words phrase in the textbox at the time of the post this sends only the first word from that phrase. I added some watches and $("#NumeAsigurat").val(); has the full phrase that I entered.

Any idea how to solve this?

Upvotes: 1

Views: 582

Answers (1)

Brad Christie
Brad Christie

Reputation: 101604

If i understand the question correctly, I think you're looking for encodeURIComponent which would make foo bar = foo%20bar (properly encoded for a URI).

Upvotes: 1

Related Questions