带有动态文本框的动态AutoCompleteExtender不会调用servicemethod [英] servicemethod not getting called for dynamic AutoCompleteExtender with dynamic textbox

查看:97
本文介绍了带有动态文本框的动态AutoCompleteExtender不会调用servicemethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过继承TextBox创建了一个文本框.现在,"oninit"创建了一个AutoCompleteExtender并分配了所有属性.代码没有引发任何错误,但是从未调用过servicemethod.

代码如下.


I created a textbox by inherting from TextBox.Now "oninit" i created an AutoCompleteExtender and assigned all the properties.The code is not throwing any error, but the servicemethod is never getting called.

Code is given below.


namespace AutoComplete
{
    [DefaultProperty("TextBox")]
    [ToolboxData("<{0}:TBControl runat=''server''></{0}:TBControl>")]
    public class DynamicTextBox : TextBox
    {
        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        private bool _isRequired;
        private string _functionId;
        private string _filterParams;

        public string FunctionId
        {
            set
            {
                _functionId = value;
            }
            get
            {
                return _functionId;
            }
        }
        public bool IsRequired
        {
            set
            {
                _isRequired = value;
            }
            get
            {
                return _isRequired;
            }
        }
        public string FilterParams
        {
            set
            {
                _filterParams = value;
            }
            get
            {
                return _filterParams;
            }
        }

        protected override void OnInit(EventArgs e)
        {

            if (_isRequired)
            {
                AjaxControlToolkit.AutoCompleteExtender _objAuto = new AjaxControlToolkit.AutoCompleteExtender();
                _objAuto.TargetControlID = this.ID;
                _objAuto.OnClientPopulated = "onClientPopulated";
                _objAuto.ServicePath = "WebService1.asmx";
                _objAuto.ServiceMethod = "GetCompletionList1";
                _objAuto.MinimumPrefixLength = 1;
                _objAuto.CompletionInterval = 1000;
                _objAuto.EnableCaching = true;
                _objAuto.CompletionSetCount = 20;
                _objAuto.CompletionListCssClass = "autocomplete_completionListElement";
                _objAuto.CompletionListItemCssClass = "autocomplete_listItem";
                _objAuto.CompletionListHighlightedItemCssClass = "autocomplete_highlightedListItem";
                _objAuto.UseContextKey = true;
                _objAuto.ContextKey = "AssetNo";
                _objAuto.FirstRowSelected = true;

                Controls.Add(_objAuto);
            }
        }

    }
}



感谢所有帮助/建议



any help/suggestions are appreciated

推荐答案

您好,我似乎在上面的代码中找不到任何问题,
但您可以检查以下内容:
1. ASMX文件中的WebService1类应使用[ScriptService]属性修饰.
2. GetCompletionList1方法应使用[ScriptMethod]和[WebMethod]属性修饰.
3. GetCompletionList1方法中的参数应为:(字符串prefixText,int计数).变量名称和大小写不能更改.

另外,您需要在ASPX页面中添加ScriptManager或ToolkitScriptManager才能使自动完成扩展程序起作用.

如果您仍然无法结帐此视频.
希望这会有所帮助:)
Hello, I can''t seem to find any issues in the code above,
but you can check for the following:
1. The WebService1 class in the ASMX file should be decorated with the [ScriptService] attribute.
2. The method GetCompletionList1 should be decorated with [ScriptMethod] and [WebMethod] attributes.
3. The parameters in the GetCompletionList1 method should be: (string prefixText, int count). The variable names and case cannot change.

Also, you need to add a ScriptManager or ToolkitScriptManager in the ASPX page for the autocompleteextender to work.

If you are still having trouble checkout this video.
Hope this helps :)


这篇关于带有动态文本框的动态AutoCompleteExtender不会调用servicemethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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