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

来源:互联网 发布:泰坦尼克号细节知乎 编辑:程序博客网 时间:2024/05/22 07:48

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


改成 Button 就可以了。

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

查找代码如下:

    string GetPostBackControlName()    {        Control control = null;        string ctrlname = Page.Request.Params["__EVENTTARGET"];        if (ctrlname != null && ctrlname != String.Empty)        {            control = Page.FindControl(ctrlname);        }        else        {            Control c;            foreach (string ctl in Page.Request.Form)            {                if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))                {                    c = Page.FindControl(ctl.Substring(0, ctl.Length - 2));                }                else                {                    c = Page.FindControl(ctl);                }                if (c is System.Web.UI.WebControls.Button ||                         c is System.Web.UI.WebControls.ImageButton)                {                    control = c;                    break;                }            }        }        if (control != null)            return control.ID;        else            return string.Empty;    }



原创粉丝点击