Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bubberz
Constraint Violating Yak Guru
289 Posts |
Posted - 2005-08-23 : 11:03:12
|
My basic goal is to add autocomplete to a dropdownlist.Here's my class below with which I'm having issues.On the Protected Overrides Sub OnLoad routine, I keep getting the syntax errors (blue underlining) for chr(34) and for vbCrLf. The indicators say "Not Declared"Imports SystemImports System.Web.UI.WebControlsNamespace Thycotic.Web.UI.WebControls Public Class KeySortDropDownList Inherits DropDownList Private Shared functionName As String = "KeySortDropDownList_onkeypress" Private _caseSensitiveKeySort As Boolean = False Public Overridable Property CaseSensitiveKeySort() As Boolean Get Return _caseSensitiveKeySort End Get Set(ByVal Value As Boolean) _caseSensitiveKeySort = Value End Set End Property Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) MyBase.OnLoad(e) ' call the base class method ' define the client-side script Dim script As String script = "<script language=" & Chr(34) & "javascript" & Chr(34) & " type=" & Chr(34) & "text/javascript" & Chr(34) & ">" & vbCrLf script &= "function " & functionName & " (dropdownlist,caseSensitive) {" & vbCrLf script &= " // check the keypressBuffer attribute is defined on the dropdownlist" & vbCrLf script &= " var undefined; " & vbCrLf script &= " if (dropdownlist.keypressBuffer == undefined) { " & vbCrLf script &= " dropdownlist.keypressBuffer = ''; " & vbCrLf script &= " } " & vbCrLf script &= " // get the key that was pressed " & vbCrLf script &= " var key = String.fromCharCode(window.event.keyCode); " & vbCrLf script &= " dropdownlist.keypressBuffer += key;" & vbCrLf script &= " if (!caseSensitive) {" & vbCrLf script &= " // convert buffer to lowercase" & vbCrLf script &= " dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase();" & vbCrLf script &= " }" & vbCrLf script &= " // find if it is the start of any of the options " & vbCrLf script &= " var optionsLength = dropdownlist.options.length; " & vbCrLf script &= " for (var n=0; n < optionsLength; n++) { " & vbCrLf script &= " var optionText = dropdownlist.options[n].text; " & vbCrLf script &= " if (!caseSensitive) {" & vbCrLf script &= " optionText = optionText.toLowerCase();" & vbCrLf script &= " }" & vbCrLf script &= " if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) { " & vbCrLf script &= " dropdownlist.selectedIndex = n; " & vbCrLf script &= " return false; // cancel the default behavior since " & vbCrLf script &= " // we have selected our own value " & vbCrLf script &= " } " & vbCrLf script &= " } " & vbCrLf script &= " // reset initial key to be inline with default behavior " & vbCrLf script &= " dropdownlist.keypressBuffer = key; " & vbCrLf script &= " return true; // give default behavior " & vbCrLf script &= "} " & vbCrLf script &= "</script>" ' register the client-side script block Me.Page.RegisterClientScriptBlock(functionName, script) ' ' add to the onkeypress event Me.Attributes.Add("onkeypress", "return " + functionName + "(this," + _caseSensitiveKeySort.ToString().ToLower() + ")") End Sub 'OnLoad End Class 'KeySortDropDownListEnd Namespace 'Thycotic.Web.UI.WebControls |
|
bubberz
Constraint Violating Yak Guru
289 Posts |
Posted - 2005-08-23 : 16:37:34
|
Used "" for chr(34) and Environment.NewLine for vbCrlf |
 |
|
|
|
|