当用户将鼠标悬停在按钮上时,我试图隐藏或显示Panel
但我没有得到任何线索如何做到这一点。我尝试使用javascript
以下方式但它显示错误元素未知属性名称..请帮助我..
我的java脚本代码:
<script type="text/javascript">
function SetMouseOver(element) {
element.Panel1.visible="True";
}
function SetMouseOut(element) {
element.Panel1.visible="False";
}
</script>
我的asp.mark代码:
<td><asp:Button ID="Button1" runat="server" class="classnameL" Text="SUMIFS"
Width="100%" onmouseover="SetMouseOver()"
/>
</td>
我的Html:
<%@ Page Language="C#" AutoEventWireup="true" Inherits="IssueResponse" MaintainScrollPositionOnPostback="true" Codebehind="IssueResponse.aspx.cs" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
</script>
----
-----
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td><asp:Button ID="Button1" runat="server" class="classnameL" Text="SUMIFS"
Width="100%" onmouseover="SetMouseOver()"
/>
</td>
</tr>
</table>
------
------
<asp:Panel ID="Panel1" runat="server" Visible="False">
-------
- -------
</asp:Panel>
</div>
</form>
</body>
</html>
这是VBA的代码
Option Compare Database
Dim dbs As DAO.Database
Dim db As DAO.Database
Dim rst As DAO.Recordset
Private Sub cmd_costDifferential_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_CostDifferential")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_CostDifferential"
Me.lblReportName.Caption = "Report for Cost Differential"
Me.Requery
End Sub
Private Sub cmd_costiszero_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_Cost_is_zero")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_Cost_is_zero"
Me.lblReportName.Caption = "Report for Cost is zero"
Me.Requery
End Sub
Private Sub cmd_Export_Click()
Call ExceExportfile
End Sub
Private Sub cmd_FinacneApproval_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_Finance_approval")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_Finance_approval"
Me.lblReportName.Caption = "Report for Finance Approval"
Me.Requery
End Sub
Private Sub cmd_FinanceRjected_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_Finance_rejected")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_Finance_rejected"
Me.lblReportName.Caption = "Report for Finance Rjected"
Me.Requery
End Sub
Private Sub cmd_highvolume_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_HigerVolume")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_HigerVolume"
Me.lblReportName.Caption = "Report for Higher Volume"
Me.Requery
End Sub
Private Sub cmd_Multiplesku_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_multiplesku_all")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_multiplesku_all"
Me.lblReportName.Caption = "Report for Multiple sku "
Me.Requery
End Sub
Private Sub cmd_NegativeMargin_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_Negative_margin")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_Negative_margin"
Me.lblReportName.Caption = "Report for Negative Margin"
Me.Requery
End Sub
Private Sub cmd_Overdue_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_Award_overdue")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_Award_overdue"
Me.lblReportName.Caption = "Report for Award Overdue"
Me.Requery
End Sub
Private Sub cmd_Supplyapproval_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_Supply_approval")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_Supply_approval"
Me.lblReportName.Caption = "Report for Supply Approval"
Me.Requery
End Sub
Private Sub cmd_Supplyrejected_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_Supply_rejected")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_Supply_rejected"
Me.lblReportName.Caption = "Report for Supply Rejected"
Me.Requery
End Sub
Private Sub cmd_TenderPrice_Click()
If rst Is Nothing Then
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qry_Tender_price")
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Me.qry_report_filter.SourceObject = "Query.qry_Tender_price"
Me.lblReportName.Caption = "Report for Tender Price"
Me.Requery
End Sub
Private Sub cmd_Upload_Click()
Dim ABook As Workbook
Dim ASheet As Worksheet
'Public objCon As New ADODB.Connection
Dim lp As String
Dim wb As Workbook
Dim ws As Worksheet
Dim SQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
'Me.frmUploaderrorreport.SourceObject = ""
If ifTableExists("Data$_ImportErrors") = True Then
DoCmd.DeleteObject acTable, "Data$_ImportErrors"
End If
Dim Answer As Integer
Answer = MsgBox("Please use the attached excel template for uploading the data in the prescribed format ", vbYesNo, "Uplod Master file ")
If Answer = 7 Then
'Me.lblwarningforupload.Visible = False
Me.Repaint
'Me.Refresh
Exit Sub
End If
DoCmd.SetWarnings False
DoCmd.OpenQuery ("qry_Delete")
DoCmd.SetWarnings True
'Me.lblwarningforupload.Visible = True
Dim dlg As FileDialog
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
.Title = "Select the Excel file to import"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Excel Files", "*.xlsx", 1
.Filters.Add "All Files", "*.*", 2
On Error GoTo end1:
If .Show = -1 Then
StrFileName = .SelectedItems(1)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "tb_MasterData", StrFileName, True, "Data!"
Else
Exit Sub
End If
MsgBox ("Report has been uploaded ")
'Me.frmUploaderrorreport.Visible = True
Exit Sub
' Me.frmUploaderrorreport.SourceObject = "Table.TenderMaster$_ImportErrors"
'Me.lblwarningforupload.Visible = False
Exit Sub
end1:
'MsgBox ("File is in the wrong format")
End With
'Me.lblwarningforupload.Visible = False
End Sub
Public Function ifTableExists(tblName As String) As Boolean
If DCount("[Name]", "MSysObjects", "[Name] = '" & tblName & "'") = 1 Then
ifTableExists = True
End If
End Function
Public Sub ExceExportfile()
On Error GoTo Command13_Click_Err
Me.qry_report_filter.SetFocus
'DoCmd.GoToControl "Policy Ref"
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
Dim xlapp As Excel.Application
Set xlapp = CreateObject("Excel.Application")
With xlapp
.Workbooks.Add
.ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:= _
False
.Cells.Select
.Cells.EntireColumn.AutoFit
.Visible = True
.Range("a1").Select
End With
Command13_Click_Exit:
Exit Sub
Command13_Click_Err:
MsgBox Error$
Resume Command13_Click_Exit
'DoCmd.OutputTo acOutputForm, "frm_Server_Data", acFormatXLS ''_
'strPath & "\ServerData.xls" ', AutoStart:=-1
Exit Sub
Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim varField As Variant
Dim lngRow As Long, lngCol As Long
Dim wb As String
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)
'On Error GoTo Err_Cancel_Click
rst.MoveFirst
lngRow = 0
Do While Not rst.EOF
lngCol = 0
For Each varField In rst.Fields
On Error Resume Next
oBook.Worksheets("Sheet1").Cells(lngRow + 1, lngCol + 1) = IIf(lngRow = 0, rst.Fields(lngCol).Name, varField.Value)
' On Error GoTo Err_Cancel_Click
lngCol = lngCol + 1
Next
If lngRow > 0 Then rst.MoveNext
lngRow = lngRow + 1
Loop
oSheet.Rows.AutoFit
oSheet.Columns.AutoFit
'oBook.SaveAs FileName:=wb
oExcel.Visible = True 'or oExcel.Quit
Set oSheet = Nothing
Set oBook = Nothing
Set oExcel = Nothing
rst.Close
Set rst = Nothing
'Exit_Cancel_Click:
' Exit Sub
'Err_Cancel_Click:
' MsgBox Err.Description
' Resume Exit_Cancel_Click
Exit Sub
End Sub
答案 0 :(得分:2)
使用此JavaScript:
function doHide()
{
document.getElementById("Panel1").style.display = "none";
}
function doShow()
{
document.getElementById("Panel1").style.display = "inline";
}
答案 1 :(得分:1)
建议使用jQuery,因为它允许您从按钮本身删除onmouseover
属性并清理标记,如下所示:
$('.classnameL').mouseover(function() {
$('.panel1').hide();
});
$('.classnameL').mouseout(function() {
$('.panel1').show();
});
<td>
<asp:Button ID="Button1" runat="server"
class="classnameL" Text="SUMIFS"
Width="100%" />
<asp:Panel ID="Panel1" runat="server" class="panel1" />
</td>