In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to parse the Asp.net Ajax control in the AutoComplete control, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
The release of the AjaxControlToolkit series of controls in Asp.net Ajax 1.0 has brought a lot of convenience to developers, but many of them do not seem to be as much as we thought. Recently, I have used a lot of AutoComplete controls in this, and found several shortcomings or errors in it:
1. The "two components with the same id" error occurs in some cases
two。 Easily lead to the problem of "unable to open Internet site, …, terminated operation" in IE
3. Even if the user enters a lot of characters, even if there is no matching result, it will still call the server method to try to get the matching value, which adds to the burden on the server.
4. The style of the autocomplete list is not very good.
5. The signature of the server method must be: string [] GetCompletionList (string prefixText, int count), and cannot get other required data from the client. This is especially fatal when there are multiple AutoComplete controls on a page that need to get data from different data sources.
To solve these problems, you first need to know how to modify the corresponding code and make it work in your own application. Fortunately, the AjaxControlToolkit series of controls in Asp.net Ajax controls are open source, so we can modify them as much as we need. Open the AjaxControlToolkit solution with VS2005, open the AutoCompleteBehavior.js file in the AutoComplete folder, modify and recompile, update the generated AjaxControlToolkit.dll file to your own project reference, and you can apply our optimized and enhanced Asp.net Ajax control AutoComplete control.
So, what specific code needs to be modified in the Asp.net Ajax control?
For * questions, you need to add the following before AjaxControlToolkit.AutoCompleteBehavior.callBaseMethod (this, 'dispose');
If (this._popupBehavior) {this._popupBehavior.dispose (); this._popupBehavior = null;}
The second question is to put
Document.body.appendChild (this._completionListElement)
This line is changed to
Element [XSS _ clean] .appendChild (this._completionListElement)
The third problem needs to be in the _ onTimerTick method, for
If (text.trim (). Length
< this._minimumPrefixLength) 这个判断增加一个条件,变成: if (text.trim().length < this._minimumPrefixLength || text.trim().length >10)
This eliminates the need to call the method to read the matching value to the server when the user's input exceeds 10 characters.
Fourth, to adjust the style of the autocomplete list, you can directly modify the following code in the initializeCompletionList method:
CompletionListStyle.backgroundColor = this._textBackground; completionListStyle.color = this._textColor; completionListStyle.border = 'solid 1px buttonshadow'; completionListStyle.cursor =' default'; completionListStyle.unselectable = 'unselectable'; completionListStyle.overflow =' hidden'
Or delete the lines and add: element.className = "completionList"; then add the definition of the style class "completionList" to the page
To solve a problem, you should use the
{prefixText: this._currentPrefix, count: this._completionSetCount}
Add a parameter to the server in this line and change it to:
{prefixText: this._currentPrefix, count: this._completionSetCount, srcId: this.get_element () .getAttribute ("srcid")
Thus, the method signature of the server's read auto-complete list item can be written as follows:
String [] GetCompletionList (string prefixText, int count, string srcId)
This means that we can pre-set an identification string to identify the source of the data for the text box that needs to apply the autocomplete function, such as the C # code: tb.Attributes.Add ("srcid", "xxx"); then, in the GetCompletionList method, we can read the data according to the parameter value passed by the client.
Some changes to the AutoComplete control of the Asp.net Ajax control will be introduced to you here. I hope it will help you to understand the Asp.net Ajax control.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.