I have a dropdownlist which when selected, needs to update the url, so I could send this updated url via jquery ajax and get the updated result and post it back. The problem i am running into now is I am not able to change one of the query string parameter value via my jquery call. How would i go about doing that. Please see below.
<div class="col-sm-5">
@{
var href = Url.Action<MassUploadIndexController>(c => c.LoadTemplateProperties(Model.ClientId, Model.UploadType, @property.Name, @property.SelectedValueId));
}
@if (!property.IsEnabled)
{
@Html.UI().DropDownList($"Properties[{@property.Name}]", selectList: @property.Options.Select(o => new SelectListItem { Text = o.Text, Value = o.Value, Selected = o.Value == @property.SelectedValueId.ToString() }), htmlAttributes: new { @class = "propertySelector", @disabled = "disabled", @data_reloadUrl = href })
}
else
{
@Html.UI().DropDownList($"Properties[{@property.Name}]", selectList: @property.Options.Select(o => new SelectListItem { Text = o.Text, Value = o.Value, Selected = o.Value == @property.SelectedValueId.ToString() }), htmlAttributes: new { @class = "propertySelector", @data_reloadUrl = href })
}
</div>
And the script
$(document).on("change", ".propertySelector", function (e) {
var link = $(this).attr('data-reloadUrl');
link.val().replace("selectedValueId=00000000-0000-0000-0000-000000000000", $(this).val());
alert(link);
$.ajax({
url: link,
success: function (data) {
var newHtml = $(data);
$("#selectpropertycontainer").html(newHtml);
}
});
});
The url that I see on the console is /site1/client/77089cca-c09d-419e-8978-72aef1133c8e/upload/loadproperties?uploadType=metadata&name=ProgramId&selectedValueId=00000000-0000-0000-0000-000000000000
The value I want to change when the dropdown value gets selected is the selectedValueId. I want to update the value to the correct guid from the dropdownlist selected value.
Let me know if you need more info. Thanks!