weixin_33694620 2011-11-03 11:28 采纳率: 0%
浏览 39

ASP.NET AJAX延迟

I'm using VS2010,C# to develop my ASP.NET web app. I have some a combo box for selecting province and another combo box for selecting cities, when user selected a province, the city combo box should immediately display cities belonging to that province. I have inserted an AJAX script manager into my page, also an AJAX update panel (both from toolbox) in which I've inserted my combo boxes. Then I enabled province combo box autopostback property so that when user changes his selection, I can detect it and change contents of city combo box accordingly. It works fine, as I load province and city names from my database into a list at page startup (of course this load process is performed in a if(!IsPostback) statement so that data is loaded only once). I think the time needed to update city combo box is a bit more than what is required, as there is a postback when user changes province combo box selection, what is the best (and correct) way of performing this operation? is it ok? are there any better ways of doing it? how can I IMMEDIATELY update city combo box after province combo box selection is changed, as currently there is a short delay.

thanks

  • 写回答

1条回答 默认 最新

  • weixin_33739523 2011-11-03 12:06
    关注

    You're always going to have a delay if you do it on the server side with an ASP.NET postback.

    Another option would be to output some JSON to your page on initial load which contains an array of all your provinces with a nested array for each province containing its respective cities.

    Then you can remove the auto postback and do everything client side with JavaScript. Whenever the selected province changes you just need to parse your JSON and add all the associated cities to the second dropdown list.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作