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

.Net not triggering Javascript on search (?) - should ignore default value

问题:当我使用 btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click, btnSearchTop.Click 时,代码完美运行并忽略默认情况下帮助用户的任何 'shown' 值,即在 'street' 框中显示 'street'.

但是当我运行 btnRiskRating_Click(sender As Object, e As CommandEventArgs) 它在这些值中所以我最终得到一个具有值的搜索(如果我然后点击 'btnSearch_Click' 它可以正常工作)。我认为这与 e As 部分有关,但这根本不是我的强项!如果您需要 javascript,我也可以弹出。

有两个 'search' 按钮,一个是 'quick link',在这个内部网站案例中,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 触发器,但现在已经修改了。