我有 Select2 V 4.02 的问题
这是我的代码
<select id="MySelect" class="form-control" runat="server" ClientIDMode="static">
<option></option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select>
<asp:Button Text="Show Select2 Result" runat="server" ID="btnShow" OnClick="btnShow_Click"/>
Run Code Online (Sandbox Code Playgroud)
jQuery:
$('#MySelect').select2({
placeholder: "-Select-"
});
Run Code Online (Sandbox Code Playgroud)
我的问题是:我可以从后面的 ASP .Net 代码中获取“MySelect”选择值吗?我从asp .net webform后面的代码中尝试了这段代码
protected void btnShow_Click(object sender, EventArgs e)
{
Response.Write(MySelect.Value);
}
Run Code Online (Sandbox Code Playgroud)
但它返回空字符串。
我在 XamarinForm 上使用 SearchBar,问题是只要搜索栏为空并且我按下搜索按钮,就不会触发 SearchCommand。
我尝试在xamarin 论坛的此链接上使用自定义渲染器, 但它不起作用。
public class CustomSearchBarRenderer : SearchBarRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
this.Control.QueryTextSubmit += (sender, args) =>
{
if (string.IsNullOrEmpty(args.Query) && Element.SearchCommand != null)
Element.SearchCommand.Execute(null);
};
}
}
}
Run Code Online (Sandbox Code Playgroud)
请帮我