用户控件在IE8版本中不起作用 [英] Usercontrol is not working in IE8 Version

查看:61
本文介绍了用户控件在IE8版本中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我创建了一个web usercontrol可编辑下拉列表。它在Mozilla Firefox中工作。但是客户端要求应用程序只能兼容IE8版本。但它在IE 8中无效。我们无法在IE8中选择选项。我们如何解决这个问题?



我把css放在这个地方的控制中。我用ui-widget类的jquery-ui.css文件。



是否有任何选项可以改变IE8版本的版本兼容性。



In my application I have created one web usercontrol Editable dropdownlist. It is working in mozilla firefox. But the client asks that application should compatability only IE8 Version. But it is not worked in IE 8.We can't select option in IE8. How we solve this problem?

I put css in that control this place. I am used jquery-ui.css file for ui-widget class.

Is there any option to change version compatability for IE8 version.

protected override void Render(HtmlTextWriter writer)
    {
        // Check if our Drop Down List is Visible
        if (Visible)
        {
            // Prepare our Style
            string style = (Width.Value > 0) ? string.Format(@" style=""width: {0}; ", Width) : string.Empty;
            if (Style.Count > 0)
            {
                if (string.IsNullOrEmpty(style)) style = @" style=""";
                foreach (string key in Style.Keys)
                {
                    style += string.Format("{0}: {1}; ", key, Style[key]);
                }
            }
            if (!string.IsNullOrEmpty(style)) style = style.TrimEnd() + @"""";

            // Check if we have any Drop Down Selections
            if (Items.Count > 0 && Enabled)
            {
                // Prepare our DropDownList
                string css = string.Format(@"class=""ui-widget ui-widget-content ui-corner-left{0}""", (string.IsNullOrWhiteSpace(CssClass)) ? string.Empty : string.Format(@" {0}", CssClass));

                List<string> dropDownItems = new List<string>();
                foreach (ListItem item in Items)
                {
                    dropDownItems.Add(item.Text);
                }
                // Create a distinct list of drop down selections from our values
                string userSelections = CreateJavascriptArray(dropDownItems);

                string tabIndex = (TabIndex > 0) ? string.Format(@" tabindex=""{0}"" ", TabIndex) : string.Empty;

                // Check if we have Custom Attributes for this control
                string customAttributes = GetCustomAttributes();
                string baseID = ClientID;
                string markup = string.Format(@"<input type=""text"" value=""{0}"" id=""{1}"" name=""{1}"" {2}{3}{4}{5}/>", Text, baseID, css, style, tabIndex, customAttributes);
                writer.Write(markup);

                string listID = string.Format("{0}_list", ClientID);
                string script = string.Format(@"$(""#{0}"").combobox( {{source: {1}, name: ""{2}"", autopostback: {3}, autoselectFirstItem: {4}}} );", baseID, userSelections, listID, (AutoPostBack || OnClick != null).ToString().ToLower(), AutoselectFirstItem.ToString().ToLower());

                // Check if we need to set focus on our combobox
                if (_setFocus)
                {
                    script += string.Format("\n$(\"#{0}\").focus();", listID);
                }

                if (ScriptManager.GetCurrent(this.Page) != null)
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "init" + ClientID, script, true);
                else
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "init" + ClientID, script, true);
            }
            else
            {
                // Standard Text Box
                string css = string.Format(@"class=""ui-widget ui-widget-content ui-corner-left ui-corner-right{0}""", (string.IsNullOrWhiteSpace(CssClass)) ? string.Empty : string.Format(@" {0}", CssClass));

                // Check if this item is Disabled
                string disabled = (Enabled == true) ? string.Empty : @" disabled=""true""";

                string markup = string.Format(@"<input type=""text"" value=""{0}"" id=""{1}"" name=""{1}"" {2}{3}{4}/>", Text, ClientID, css, style, disabled);
                writer.Write(markup);
            }
        }
    }

推荐答案

(#{0})。组合框({{来源:{1},名称:{2},autopostback:{3},autoselectFirstItem:{4}}});,baseID,userSelections,listID,(AutoPostBack | | OnClick!= null )。ToString()。ToLower(),AutoselectFirstItem.ToString()。ToLower());

// 检查我们是否需要关注我们的组合框
if (_ setFocus)
{
script + = string .Format( \ n
(""#{0}"").combobox( {{source: {1}, name: ""{2}"", autopostback: {3}, autoselectFirstItem: {4}}} );", baseID, userSelections, listID, (AutoPostBack || OnClick != null).ToString().ToLower(), AutoselectFirstItem.ToString().ToLower()); // Check if we need to set focus on our combobox if (_setFocus) { script += string.Format("\n


(\#{0} \)。focus();,listID);
}

if (ScriptManager.GetCurrent( this .Page) != null
ScriptManager.RegisterStartupScript( this this .GetType(), init + ClientID,script,);
else
this .Page.ClientScript.RegisterStartupScript( this .GetType(), init + ClientID,脚本, true );
}
其他
{
// < span class =code-comment>标准文本框
字符串 css = string .Format( @ class =ui-widget ui-widget-content ui-corner-left ui- corner-right {0},( string .IsNullOrWhiteSpace(CssClass))? string .Empty: string .Format( @ { 0},CssClass));

// 检查此项目是否已停用
string disabled =(启用== true )? string .Empty: @ disabled =true ;

string markup = string .Format( @ < input type =textvalue ={0}id ={1}name = {1}{2} {3} {4} />,Text,ClientID,css,style,disabled);
writer.Write(markup);
}
}
}
(\"#{0}\").focus();", listID); } if (ScriptManager.GetCurrent(this.Page) != null) ScriptManager.RegisterStartupScript(this, this.GetType(), "init" + ClientID, script, true); else this.Page.ClientScript.RegisterStartupScript(this.GetType(), "init" + ClientID, script, true); } else { // Standard Text Box string css = string.Format(@"class=""ui-widget ui-widget-content ui-corner-left ui-corner-right{0}""", (string.IsNullOrWhiteSpace(CssClass)) ? string.Empty : string.Format(@" {0}", CssClass)); // Check if this item is Disabled string disabled = (Enabled == true) ? string.Empty : @" disabled=""true"""; string markup = string.Format(@"<input type=""text"" value=""{0}"" id=""{1}"" name=""{1}"" {2}{3}{4}/>", Text, ClientID, css, style, disabled); writer.Write(markup); } } }


这篇关于用户控件在IE8版本中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆