预输入数据文本框未重置



我有一个包含预先输入文本框的应用程序。用户希望提前输入使用"而不是"Contains"为了搜索。我的同事写了一些javascript来启用"搜索。效果很好……直到我点击添加按钮。然后,列表不会刷新所有选项。我的意思是:文本框/数据列表开始(在加载/刷新页面时)填充如下:
苹果
杏子
鳄梨
香蕉
黑莓
蓝莓
樱桃
椰子
蔓越莓


如果我开始输入C,文本框/数据列表现在包含:
樱桃
椰子
蔓越莓


如果我选择Cherry,然后单击Add,我希望列表返回到包含所有水果的原始状态,但是它保留了Cherry的值,删除Cherry只会添加以"C"开头的其他水果。所以列表还是:
樱桃
椰子
蔓越莓


我需要所有的水果回到列表后添加。请参阅以下代码:
从aspx:

<datalist id="dlParentFruit">
<asp:PlaceHolder ID="phParentFruit" runat="server"></asp:PlaceHolder>
</datalist>
<asp:TextBox ID="txtAddStdFruit" list="dlParentFruit" runat="server" Width="200px" MaxLength="250"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="fteAddFruit" runat="server" TargetControlID="txtAddStdFruit" FilterType="Custom" FilterMode="InvalidChars" InvalidChars="&quot;'[]{}|^~`!@#$"></ajax:FilteredTextBoxExtender>
<asp:Panel ID="pnlValAddFruit" runat="server" CssClass="cse-val-tooltip cse-hide">
<img src="../Images/triangle.png" alt="validation error" />
<ul id="vulAddFruit" runat="server"></ul>
</asp:Panel>
<asp:RequiredFieldValidator ID="rfvAddStdFruit" runat="server"
ErrorMessage="Required: Fruit"
ControlToValidate="txtAddStdFruit"
Display="None"
ValidationGroup="Add"
data-val="pnlValAddFruit">
</asp:RequiredFieldValidator>

(VB):
' ' 'Private Sub btnAddStdFruit_Click(ByVal sender作为Object, ByVal e作为EventArgs)处理btnAddStdFruit。点击试一试如果是IsErrorShownForAdd则ResetAddValidation ()如果
Page.Validate("Add")
If IsAddValid() Then
Dim dateMin As DateTime = Me.StdDate & " " & Helper.SetTime(txtAddStart.Text)
Dim dateMax As DateTime
If txtAddStop.Text = 2400 Then
dateMax = Helper.setMidnight(Me.StdDate, txtAddStop.Text)
Else
dateMax = Me.StdDate & " " & Helper.SetTime(txtAddStop.Text)
End If
Dim itemSelected As New ListItem
Dim ctrAddedFrts As Integer = 0
Dim bolDupeRow As Boolean = False
Dim strResourceList As String = String.Empty
For Each itemSelected In lbLocationResource.Items
If itemSelected.Selected = True Then
bolDupeRow = IsFruitDuplicate(-1, itemSelected.Text, dateMin, dateMax, txtAddStdFruit.Text, ddlAddCategory.SelectedValue)
If bolDupeRow = False Then
MRData.AddStdFruit(Me.StdID, txtAddStdFruit.Text, itemSelected.Value, dateMin, dateMax, ddlAddCategory.SelectedValue, Me.UserID, "Edit All Frt - Added Fruit")
ctrAddedFrts += 1
End If
strResourceList = strResourceList & itemSelected.Value & ","
End If
Next
If strResourceList.Length > 0 Then
'Remove last comma
strResourceList = strResourceList.Substring(0, strResourceList.Length - 1)
Me.SelectedResourceList = strResourceList
End If

If ctrAddedFrts > 0 Then
txtAddStart.Text = String.Empty
txtAddStop.Text = String.Empty
pnlValAddLocation.CssClass = Constants.VALIDATOR_PANEL_RESET_STYLE
ResetStdRequestSet()
ResetMenuFruitList()
ResetStandardFruitList()
BindLists()
BindStdFruits()

ElseIf ctrAddedFrts = 0 AndAlso bolDupeRow = False Then
IsErrorShownForAdd = True
pnlValAddLocation.CssClass = Constants.VALIDATOR_PANEL_STYLE
lbLocationResource.CssClass = "cse-select-error"
Dim listItem As New HtmlGenericControl("li")
listItem.InnerHtml = Helper.FormatErrorMessage("Error: Location must be chosen")
vulAddLocation.Controls.Add(listItem)

ElseIf ctrAddedFrts = 0 AndAlso bolDupeRow = True Then
IsErrorShownForAdd = True
pnlValAddLocation.CssClass = Constants.VALIDATOR_PANEL_STYLE
lbLocationResource.CssClass = "cse-select-error"
Dim listItem As New HtmlGenericControl("li")
listItem.InnerHtml = Helper.FormatErrorMessage("Error: Duplicate Fruit")
vulAddLocation.Controls.Add(listItem)
End If
End If
pnlAddStdFruits.Attributes.Add("style", "display: New;")
hlAddFruits.InnerText = "-Add Fruits"
upnlStdFruits.Update()
Catch ex As Exception
AppUtilities.HandleError(ex, Me.Page, Identity.SystemUserID, Constants.SITE_ID, PAGE_NAME)
End Try

结束子

子BindLists ()ddlAddCategory。数据源=我。FruitCategoryListddlAddCategory。DataTextField ="Fruit_CATEGORY"ddlAddCategory。DataValueField = "Fruit_CATEGORY_ID"ddlAddCategory.DataBind ()ddlAddCategory.Items。Insert(0, New WebControls.ListItem(", -1))ddlAddCategory。selectedinindex = 0

phParentFruit.Controls.Clear()

Dim dtFruits As DataTable = Me.StandardFruitList
Dim hgcParentList As New HtmlGenericControl
hgcParentList.InnerHtml = Helper.BuildDatalist(dtFruits, "Fruit_TEXT", "LU_ID_CAT")
phParentFruit.Controls.Add(hgcParentList)

结束子

Public Sub BindStdFruits(可选ByVal dt As DataTable = Nothing)将dtstdfirst定义为数据表如果我。MenuFruitList什么都不是ResetMenuFruitList ()dtstdfirst = Me。MenuFruitList其他的dtstdfirst = Me。MenuFruitList如果

If Me.StandardFruitList Is Nothing Then
ResetStandardFruitList()
End If
If dtStdFrts.Rows.Count > 0 Then
gvStdFrt.DataSource = dtStdFrt
gvStdFrt.DataBind()
lblGridMessage.Text = String.Empty
lblGridMessage.Visible = False
If Not Me.IsReadOnly Then
hlMassTime.Visible = True
btnDelete.Visible = True
btnUpdate.Visible = True
Else
hlMassTime.Visible = False
btnDelete.Visible = False
btnUpdate.Visible = False
End If
gvStdFrt.Visible = True
Else
lblGridMessage.Visible = True
lblGridMessage.Text = "No menu Fruits"
If (hlAddFruits.Visible = True) Then
pnlAddStdFruits.Attributes.Add("style", "display: New;")
hlAddFruits.InnerText = "-Add Fruits"
End If
btnDelete.Visible = False
btnUpdate.Visible = False
hlMassTime.Visible = False
gvStdFrt.Visible = False
End If
upnlStdFruits.Update()

结束子

子ResetStandardFruitList ()将dtstdfirst定义为数据表dtstdfirst = MIMData.GetStandardFruitByType("标准")我。StandardFruitList = dtstdstdfirst终止子

<br />
JavaScript:<br />

方法。addNewFruitsFruitListStartsWith =函数(txtFruit) {

if (typeof txtFruit !== 'undefined' && txtFruit !== null && txtFruit.nodeName === 'INPUT' &&
Controls.addPanelFruitOptions !== null && typeof Controls.addPanelFruitOptions !== 'undefined' &&
Inputs.initialAddPanelFruitDataListContent !== null && typeof Inputs.initialAddPanelFruitDataListContent !== 'undefined') {
var value = txtFruit.value;
if (typeof value !== 'undefined' && value !== '') {
var options = '';
for (var i = 0; i < Controls.addPanelFruitOptions.length; i++) {
if (Controls.addPanelFruitOptions[i].value.toLowerCase().startsWith(value.toLowerCase())) {
options += '<option value="' + Controls.addPanelFruitOptions[i].value + '" />';
}
}
Controls.addPanelFruitDataList.innerHTML = options;
} else {
Controls.addPanelFruitDataList.innerHTML = Inputs.initialAddPanelFruitDataListContent;
}
}

}

<代码>

DataList中,我必须将UpdatePanel控制移动到CC_4。愚蠢的错误!

相关内容

  • 没有找到相关文章

最新更新