Rea Posted January 26, 2006 Posted January 26, 2006 Hai, I placed the scrip from web page Custom Control - KeySortDropDownList) to my project ContactSearch.ascx.cs Sours: 1. namespace vestinside.Controls 2. { 3. using System; 4. using System.Data; 5. using System.Drawing; 6. using System.Web; 7. using System.Web.UI.WebControls; 8. using System.Web.UI.HtmlControls; 9. using vestinside.DB; 10. using vestinside.Library; 11. 12.namespace Thycotic.Web.UI.WebControls 13.{ 14.public class KeySortDropDownList : DropDownList 15.{ 16...... After compiling I got the following error: O:\localhost\Controls\ContactSearch.ascx.cs(12): Cannot use qualified namespace names in nested namespace declarations Projekt: ASP.net C# How to eliminate this error? Maybe I paste to bad place? Thanks Quote
Administrators PlausiblyDamp Posted January 26, 2006 Administrators Posted January 26, 2006 You cannot nest the line namespace Thycotic.Web.UI.WebControls inside an already existing namespace. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Rea Posted January 27, 2006 Author Posted January 27, 2006 (edited) How to make the script working? When I delete namespace Thycotic.Web.UI.WebControls, the error has gone, but when I type to Dropdownlist 'ae' , I got in the first in the list 'a...' and then 'e...', but not 'ae....'" How to make the script working? namespace vestinside.Controls { using System; using System.Data; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using vestinside.DB; using vestinside.Library; public class KeySortDropDownList : DropDownList { private readonly static string functionName = "KeySortDropDownList_onkeypress"; private bool _caseSensitiveKeySort = false; public virtual bool CaseSensitiveKeySort { get { return _caseSensitiveKeySort; } set { _caseSensitiveKeySort = value; } } protected override void OnLoad(System.EventArgs e) { base.OnLoad(e);// call the base class method // define the client-side script string script = @" <script language=""javascript"" type=""text/javascript""> function " + functionName + @"(dropdownlist,caseSensitive) { // check the keypressBuffer attribute is defined on the dropdownlist var undefined; if (dropdownlist.keypressBuffer == undefined) { dropdownlist.keypressBuffer = ''; } // get the key that was pressed var key = String.fromCharCode(window.event.keyCode); dropdownlist.keypressBuffer += key; if (!caseSensitive) { // convert buffer to lowercase dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase(); } // find if it is the start of any of the options var optionsLength = dropdownlist.options.length; for (var n=0; n < optionsLength; n++) { var optionText = dropdownlist.options[n].text; if (!caseSensitive) { optionText = optionText.toLowerCase(); } if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) { dropdownlist.selectedIndex = n; return false; // cancel the default behavior since // we have selected our own value } } // reset initial key to be inline with default behavior dropdownlist.keypressBuffer = key; return true; // give default behavior } </script>"; // register the client-side script block this.Page.RegisterClientScriptBlock(functionName,script); // add to the onkeypress event this.Attributes.Add("onkeypress","return " + functionName + "(this," + _caseSensitiveKeySort.ToString().ToLower() + ")"); } } ................ Edited January 27, 2006 by Rea Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.