c# - 使用 javascript 更新用户控件时,如何同步后面的代码?
问题描述
我有一个自定义用户控件,可用作从端点ASP
DropDownList
异步检索数据的可重用控件RESTful
<myControls:AjaxDropDown ID="ddlDropdown" runat="server" ServicePath="/MyWebService2.asmx/GetLetterTypes"/>
在用户控件中,我通过成功更新下拉内容$.ajax
$.ajax({
type: "GET",
dataType: "json",
url: $('#<%=textBoxUrlPath.ClientID %>').val(),
contentType: "application/json; charset=utf-8",
async: true,
success: function(res) {
onGetLetterTypesSuccess(res);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
如何将检索到的数据$.ajax
与用户控件背后的代码同步?
我使用$.ajax
而不是通过UpdatePanel
控件进行部分更新的原因是由于 UpdatePanel 无法在单个页面上一次进行多个异步调用。
解决方案
我决定不走这条客户端更新路线,因为它直接反对 Web 表单结构。相反,我将满足于从后面的代码进行此调用并在提供页面之前填充 DropDownList 的同步解决方案。
推荐阅读
- html - 我无法使用 td colspan 和 rowspan 创建此表
- c# - 如何将泛型类型传递给泛型方法?
- javascript - 试图只使用高阶函数来制作中继器功能?
- c++ - 使用 constexpr 和 std::array 静态初始化获取闰年以替换动态初始化的 std::vector
- css - 大众单位中定义的字体大小在桌面中显得太大
- azure-logic-apps - 如何在逻辑应用(天蓝色)中更改撰写连接器的顺序。默认为 asc 命令
- reactjs - 当我尝试推送我的应用程序时,heroku 一直给我这个错误
- spring - spring如何在没有控制器映射的情况下解析.jsp页面
- javascript - 如何在递归操作中携带结果
- mysql - 如何在 MySql 中计算唯一性和重复性