关键词搜索

源码搜索 ×
×

WAP版浏览器不支持.NET的linkButton

发布2012-11-06浏览2325次

详情内容

在我们网站FOR WAP版的某个页面上放了两个LinkButton,结果用手机自带的WAP浏览器看的时候,提示 通信协议不支持。


改成 Button 就可以了。

ImageButton的话,点击不会报错,页面虽然刷新,但没有执行相应的事件。不过页面确实是有提交的,只是没有跟ImageButton的事件挂钩。可以在Page_Load里查出是哪个控件触发了提交,如果发现是这个ImageButton的话,就执行它的事件。关键是怎么找出是谁触发了提交。

查找代码如下:

  1. string GetPostBackControlName()
  2. {
  3. Control control = null;
  4. string ctrlname = Page.Request.Params["__EVENTTARGET"];
  5. if (ctrlname != null && ctrlname != String.Empty)
  6. {
  7. control = Page.FindControl(ctrlname);
  8. }
  9. else
  10. {
  11. Control c;
  12. foreach (string ctl in Page.Request.Form)
  13. {
  14. if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
  15. {
  16. c = Page.FindControl(ctl.Substring(0, ctl.Length - 2));
  17. }
  18. else
  19. {
  20. c = Page.FindControl(ctl);
  21. }
  22. if (c is System.Web.UI.WebControls.Button ||
  23. c is System.Web.UI.WebControls.ImageButton)
  24. {
  25. control = c;
  26. break;
  27. }
  28. }
  29. }
  30. if (control != null)
  31. return control.ID;
  32. else
  33. return string.Empty;
  34. }



相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载