gpt4 book ai didi

javascript - .Net 在搜索时不触发 Javascript(?) - 应该忽略默认值

转载 作者:行者123 更新时间:2023-11-28 07:42:57 25 4
gpt4 key购买 nike

问题:当我使用 btnSearch_Click(sender As Object, e As EventArgs) 处理 btnSearch.Click、btnSearchTop.Click 时,代码完美运行,并忽略默认情况下提供帮助的任何“显示”值用户,即在“街道”框中显示“街道”。

但是,当我运行 btnRiskRating_Click(sender As Object, e As CommandEventArgs) 时,它位于这些值中,因此我最终得到的搜索具有以下值(如果我随后点击“btnSearch_Click”)工作正常)。我认为 e As 部分是这样的,但这根本不是我的强项!如果你需要 javascript 我也可以弹出它。

有两个“搜索”按钮,其中一个是“快速链接”,基本上在这个内部网站情况下 80-90% 的情况下,这就是他们所需要的。

Protected Sub btnRiskRating_Click(sender As Object, e As CommandEventArgs)

Dim vRiskRating As String = Trim(e.CommandArgument.ToString())

Session.Item("sRiskRating") = vRiskRating.ToString

With oAuditData
.EventType = "LOG"
.EventDescription = "User clicked Risk Rating " & vRiskRating.ToString & ""
.PemcoModule = "All"
.SiteID = 0
.UserID = CInt(oUser.UserID)
.EmployeeID = Session("EmployeeID")
End With
oAudit.WriteAuditTrailItem(oAuditData)


Call PrcSearch()

End Sub

Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click, btnSearchTop.Click

Call PrcSearch()

End Sub

Public Sub PrcSearch()

Session.Item("sUPRN") = Trim(sUPRN.Text)
Session.Item("sStreet") = Trim(sStreet.Text)
Session.Item("sSurveyCompany") = Trim(sSurveyCompany.Text)
Session.Item("sPostcode") = Trim(sPostcode.Text)
Session.Item("sPropertyName") = Trim(sPropertyName.Text)
Session.Item("sDateFrom") = sDateFrom.Text
Session.Item("sDateTo") = sDateTo.Text

Dim vSearch As String

vSearch = Trim(sUPRN.Text) & " - " & Trim(sSurveyCompany.Text) & " - " & Trim(sPostcode.Text)
vSearch = vSearch & " - " & Trim(sPropertyName.Text) & " - "
'& Trim(sDateFrom.Text) & " - " & Trim(sDateTo.Text)

With oAuditData
.EventType = "LOG"
.EventDescription = "User searched " & vSearch & ""
.PemcoModule = "All"
.SiteID = 0
.UserID = CInt(oUser.UserID)
.EmployeeID = Session("EmployeeID")
End With
oAudit.WriteAuditTrailItem(oAuditData)

Call PrcActionsCSVReport()

With oAuditData
.EventType = "LOG"
.EventDescription = "User search CSV created " & vSearch & ""
.PemcoModule = "All"
.SiteID = 0
.UserID = CInt(oUser.UserID)
.EmployeeID = Session("EmployeeID")
End With
oAudit.WriteAuditTrailItem(oAuditData)
End Sub

JavaScript

 $(document).ready(function () {

$('input.Date').datepicker({
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
numberOfMonths: 2,
defaultDate: "0w"
});

function showMore() {
$('div.Search div.Filter ul.More').slideDown(500);
$('div.Search div.Filter span.Right').text('Show less search options');
}
function hideMore() {
$('div.Search div.Filter ul.More').slideUp(500);
$('div.Search div.Filter span.Right').text('Show more search options');
}

$('div.Search div.Filter span.Right').on('click', function () {

if ($(this).text() == 'Show more search options')
showMore();
else
hideMore();
});

$('input.Validate').on('focusin', function () {
if ($(this).val() == $(this).attr('placeholder'))
$(this).val('');
});

$('input.Validate').on('focusout', function () {
$(this).validate();
if ($(this).val() == '')
$(this).val($(this).attr('placeholder'));
});

$('form').on('submit', function () {
var error = false;

// Validate all the fields just to be sure
$('input.Validate').each(function () {
var val = $(this).val();
if ($(this).val() == $(this).attr('placeholder'))
$(this).val('');
if (!$(this).validate())
{
alert($(this).attr('name'));
error = true;
}
$(this).val(val);
});

// If there was an error don't submit data
if (error) return false;

$('input.Validate').each(function () {
if ($(this).val() == $(this).attr('placeholder'))
$(this).val('');
});
});

});

最佳答案

我发现我们有一个 javascript 代码只能在 btnSearch 触发器上工作,但现在已经修改了。

关于javascript - .Net 在搜索时不触发 Javascript(?) - 应该忽略默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27800493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com