我有一个ajax auto complete extender,自定义webservices在.aspx页面的文本框中填充列表。 IE工作正常但在使用Chrome或Firefox时,此文本框附加了autocomplete = off属性,这与我需要的完全相反。我尝试在css类中更改z-index,在文本框中添加内联的autocomplete =,通过JavaScript删除焦点上的auto complete属性,删除pageload上的auto complete属性并设置top的auto complete属性级别主页面打开。 该页面上有一些jquery支持拖放功能,但我一直无法找到是否导致添加该属性。我没有想法,可以使用一些指导。
编辑:忘记提及当我在同一个应用程序的测试页面上放置一个文本框和autocompleteextender时,使用相同的Web服务它可以正常工作。当我检查元素时,它仍然具有autocomplete = off属性,但它似乎不会影响该功能。谢谢!
aspx page code:
<ajax:AutoCompleteExtender ID="acDisciplines" runat="server" TargetControlID="txtDisciplinesAuto" ServiceMethod="GetDisciplinesAuto" MinimumPrefixLength="1" CompletionInterval="100" EnableCaching="true" FirstRowSelected="true" CompletionListCssClass="autoCompleteExtenderList" CompletionSetCount="20"
>
</ajax:AutoCompleteExtender>
<asp:TextBox ID="txtDisciplinesAuto" runat="server" EnableViewState="false"></asp:TextBox>
css:
.autoCompleteExtenderList
{
z-index: 10009;
border: 1px solid black;
width: auto !important;
padding-right: 10px;
padding-left: 10px;
background-color: White;
max-height: 400px !important;
position: absolute;
x-overflow:hidden;
y-overflow:scroll;
}
jquery/javascript just in case:
<script type="text/javascript">
$(init);
function init() {
$('[id$=divMoveHelp]').hide();
$('[id$=divHelp]').hide();
$('[id$=lnkHelp]').click(helpLinkClicked);
$('.dragClass').draggable({
containment: 'document',
revert: 'invalid'
});
$('.dropHeader').droppable({
activeClass: 'classMoveActive',
hoverClass: 'classMoveHover',
drop: handleDropEvent,
activate: handleDragActive,
deactivate: handleDragStop
});
}
function helpLinkClicked() {
if ($('[id$=divHelp]').css('display') == 'none') {
$('[id$=divHelp]').show();
}
else {
$('[id$=divHelp]').hide();
}
}
function handleDragActive(event, ui) {
$('[id$=divMoveHelp]').show();
}
function handleDragStop(event, ui) {
$('[id$=divMoveHelp]').hide();
}
function handleDropEvent(event, ui) {
var draggable = ui.draggable;
var classText = getClassText(draggable);
var termText = $(this).text().trim();
var yearRowID = $(this).parents('[id$=tblYearGrid]').find('[id$=lblYearRowIDInner]').html().trim();
var edPlanID = $(this).parents('[id$=tblYearGrid]').find('[id$=lblEdPlanIDInner]').html().trim();
var classID = $(draggable).parent().children('.classID').text().trim();
var titleText = $(draggable).children('a').attr('title').trim();
var originTerm = $(draggable).children('a').attr('id');
if (originTerm.indexOf('Fall') >= 0) {
originTerm = 'Fall';
}
else if (originTerm.indexOf('Winter') >= 0) {
originTerm = 'Winter';
}
else if (originTerm.indexOf('Spring') >= 0) {
originTerm = 'Spring';
}
else if (originTerm.indexOf('Summer') >= 0) {
originTerm = 'Summer';
}
$(draggable).hide();
$('[id$=txtClass]').val(classText);
$('[id$=txtTerm]').val(termText);
$('[id$=txtYearRowID]').val(yearRowID);
$('[id$=txtClassID]').val(classID);
$('[id$=txtClassTitle]').val(titleText);
$('[id$=txtOriginTerm]').val(originTerm);
$('[id$=txtEdPlanID]').val(edPlanID);
$('[id$=btnMoveClass]').click();
}
function getClassText(obj) {
var val = $(obj).text().trim();
return val;
}
//override the autocomplete for chrome and firefox
var autocompleteTB;
// After the document has loaded, manipulate DOM elements.
window.addEventListener('load', function () {
// Get the username field element.
autocompleteTB = $get('<%= txtDisciplinesAuto.ClientID %>');
// Listen to the 'focus' event on the input element.
autocompleteTB.addEventListener('focus', function () {
// Remove the autocomplete attribute when the textbox comes in focus
autocompleteTB.setAttribute('autocomplete', 'on');
}, false);
}, false);
</script>