问题描述
我在我们的项目中使用了 select2 组件,我想改进 select 的使用。此选择组件具有多项选择并绑定到列表以获取值。在控制器中获取值没有问题,但我的 url 显示为 ;
localhost/Apartment?iller=1&iller=2&minf=0&maxf=0&minb=0&maxb=0
但我想将我的网址设为 localhost/Apartment?iller=1,2&minf=0&maxf=0&minb=0&maxb=0
。我怎样才能做到这一点?
<form asp-controller="EndUser" asp-action="Apartment" method="get">
<div class="col-12">
<label>İl</label>
<select multiple style="width: 100%;height:30px" id="selectIlSec" asp-for="ApartmanFilters.CokluIlId" name="iller"
asp-items="@(new MultiSelectList(Model.Iller,"Id","Ad"))">
<option value="0">Lütfen Seçim Yapınız</option>
</select>
</div>
<button type="submit" style="width:100%;" class="btn btn-md p-2 mt-3 mb-3 btn-danger"> Ara </button>
/*Another components here*/
</form>
过滤器类如下;
public class ApartmanListFilter
{
[FromQuery(Name = "iller")]
public List<long> CokluIlId{ get; set; }
//Another properties
}
也是控制器
[HttpGet]
public async Task<ActionResult> Apartment([FromQuery] ApartmanListFilter filters,int page = 1)
{
}
脚本:
$("#selectIlSec").select2({
width: 'resolve',placeholder: "İl Seçiniz",});
我正在从查询中获取值,但我只想更改上面提到的 url。谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)