控件Name.Attributes("onclick") = "javascript:window.open('YourUrl')"

解决方案 »

  1.   

    客户端的代码还是和原来asp一样的呀,服务器端代码采用的是绑定方式来写的
    '*程序功能:用于电子公告信息列表
    '*作    者:张  俊
    '*修改时间:2002/03/04Imports eOMPClass
    Imports System.Data
    Imports System.Data.SqlClient
    Public Class ElBullList
        Inherits System.Web.UI.Page
        Protected WithEvents lbSubject As System.Web.UI.WebControls.Label
        Protected WithEvents lbAuthor As System.Web.UI.WebControls.Label
        Protected WithEvents lbTime As System.Web.UI.WebControls.Label
        Protected WithEvents lbTypeName As System.Web.UI.WebControls.Label
        Protected WithEvents lbContent As System.Web.UI.WebControls.Label
        Protected WithEvents trAttach As System.Web.UI.HtmlControls.HtmlTableRow
        Protected WithEvents tdAttach As System.Web.UI.HtmlControls.HtmlTableCell
        Protected WithEvents tdHr As System.Web.UI.HtmlControls.HtmlTableCell
        Protected WithEvents ShowSpan As System.Web.UI.HtmlControls.HtmlGenericControl
        Dim sqlQry As New SqlQuerySimple()
        Dim UserChk As New AccessSecurity()
    #Region " Web Form Designer Generated Code "    'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()    End Sub    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub#End Region    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            On Error GoTo lbError        'UserChk.RightChk(, 139, , )
            Dim dsResult As New DataTable()
            Dim strSQL As String
            Dim sTitle As String
            Dim sContent As String
            Dim sDepartMent As String
            Dim sUserName As String
            Dim sDate As String
            Dim sElBullNo As String        If Trim(Request.QueryString("ElBullNo")) <> "" Then       '承接传来的公告号
                sElBullNo = Trim(Request.QueryString("ElBullNo"))
            End If        If Trim(Session("iUserId")) = "" Then
                Response.Redirect("../Warning.aspx")
                Exit Sub
            End If        strSQL = "delete from T_OMPPromptInfo where InfoTypeID='3' and InfoID='" + CStr(CInt(sElBullNo)) + "' and UserID='" + Trim(Session("iUserId")) + "'"
            sqlQry.InsUpdDelQry(strSQL)        strSQL = "select * from T_ElBulletin where ElBullNo='" + sElBullNo + "'"
            dsResult = sqlQry.Query(strSQL)    '取出该条公告内容        If dsResult.Rows.Count > 0 Then    '若该记录存在
                sTitle = Trim(dsResult.Rows(0).Item("ElBullTitle"))
                sContent = RTrim(dsResult.Rows(0).Item("ElBullContent"))
                sDate = Trim(dsResult.Rows(0).Item("ElBullDate"))
                sDepartMent = Trim(dsResult.Rows(0).Item("ElBullDept"))
            Else
                Response.Write("<script language='javascript'>")
                Response.Write("alert('对不起,该条公告不存在!');")
                Response.Write("window.close();")
                Response.Write("</script>")
                Exit Sub
            End If        lbSubject.Text = sTitle
            ShowSpan.InnerHtml = sContent
            'Response.Write(sContent)        'lbContent.Text = sContent
            lbTime.Text = sDate
            lbAuthor.Text = sDepartMent
            lbTypeName.Text = "电子公告"
            Call ShowAttachList(sElBullNo)        'Response.Write("<table border='0' cellpadding='0' cellspacing='0' align='center' width='80%'><tr><td height='25px'>&nbsp;</td></tr><table>")
            'Response.Write("<table border='1' cellpadding='0' cellspacing='0' align='center' width='80%' bordercolor='#6699CC'><tr><td>")
            'Response.Write("<table border='0' cellpadding='0' cellspacing='0' align='center'><tr><td colspan='8' height='10px' width='376px'>&nbsp;</td></tr>")
            'Response.Write("<tr><td colspan='8' align='center' class='Title'>" + sTitle + "</td></tr><tr><td colspan='8'>")
            'Call OutPutContent(sContent)    '按格式输出公告内容
            'Response.Write("</td></tr><tr><td colspan='6'>&nbsp;</td><td colspan='2' align='center'>" + sDepartMent + "</td></tr>")
            'Response.Write("<tr><td colspan='6'>&nbsp;</td><td colspan='2' align='center'>" + sDate + "</td></tr>")
            'Response.Write("<tr><td colspan='8' height='8px'>&nbsp;</td></tr></table></td></tr></table>")
            'Call ShowAttachList(sElBullNo)
            'Response.Write("<table border='0' cellpadding='0' cellspacing='0' width='80%' align='center'>")
            'Response.Write("<tr><td align=right><input type='button' class='btnRaise' style='width:68px;height:26px' value='关闭' onclick='return window.close()'>")
            'Response.Write("</td></tr></table>")
            Exit Sub
    lbError:
            Response.Write("<script language='javascript'>" + Chr(13) + "alert('系统发生意外错误,请重试或联系相关部门!')" + Chr(13) + "</script>")
        End Sub    Private Sub OutPutContent(ByVal sOutString As String)
            On Error GoTo lbError
            Dim sOutChar As String
            Dim iLoop As Integer
            Dim iBlank As Integer        For iLoop = 0 To sOutString.Length - 1
                sOutChar = Mid(sOutString, iLoop + 1, 1)   '取出当前字符            If Asc(sOutChar) = 32 Or Asc(sOutChar) = 13 Then
                    If Asc(sOutChar) = 32 Then     '若当前字符为空字符
                        Response.Write("&nbsp;")
                    End If                If Asc(sOutChar) = 13 Then     '若当前字符为换行字符
                        Response.Write("<br>")
                    End If
                Else
                    Response.Write(sOutChar)       '输出字符
                End If
            Next
            Exit Sub
    lbError:
            Response.Write("<script language='javascript'>" + Chr(13) + "alert('系统发生意外错误,请重试或联系相关部门!')" + Chr(13) + "</script>")
        End Sub    Private Sub ShowAttachList(ByVal sBullNo As String)
            On Error GoTo lbError
            Dim strSQL As String
            Dim dsResult As New DataTable()
            Dim iLoop As Integer        strSQL = "select ElBullNo,ElFileName,ElAttachNo,ElFileType from T_ElBullEncls where ElBullNo='" + sBullNo + "'"
            dsResult = sqlQry.Query(strSQL)        If dsResult.Rows.Count < 1 Then
                Exit Sub
            Else
                Me.tdHr.InnerHtml = "<hr style='color:red'>"
            End If        For iLoop = 0 To dsResult.Rows.Count - 1
                Dim MyCell As New HtmlTableCell()
                Dim MyLabel As New Web.UI.WebControls.Label()
                MyLabel.Text = "<a Target='Blank' href='ElReadAttach.aspx?ElBullNo=" + sBullNo + "&AttachNo=" + Trim(dsResult.Rows(iLoop).Item("ElAttachNo")) + "'>附件" + CStr(iLoop + 1) + ":" + Trim(dsResult.Rows(iLoop).Item("ElFileName")) + "</a><br>"
                'MyLabel.Text = "<a Target='Blank' href='../../Include/ReadAttach.asp?FileName=" + Trim(dsResult.Rows(iLoop).Item("ElFileName")) + "&FileType=" + Trim(dsResult.Rows(iLoop).Item("ElFileType")) + "&ElBullNo=" + sBullNo + "&AttachID=" + Trim(dsResult.Rows(iLoop).Item("ElAttachNo")) + "&QueryFlag=2'>" + Trim(dsResult.Rows(iLoop).Item("ElFileName")) + "</a><br>"
                MyCell = tdAttach
                MyCell.Controls.Add(MyLabel)
            Next
            Exit Sub
    lbError:
            Response.Write("<script language='javascript'>" + Chr(13) + "alert('系统发生意外错误,请重试或联系相关部门!')" + Chr(13) + "</script>")
        End Sub
    End Class
    这是服务器端代码
      

  2.   

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="ElBullList.aspx.vb" Inherits="eOMPWebMe.ElBullList" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>电子公告</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
    <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <!--<LINK id="LinkCss" href="../../css/standard.css" rel="stylesheet">-->
    </HEAD>
    <script language="javascript">
    <!--
    function OpenPage(ElBullNo,AttachNo)
    {
    window.open('ElReadAttach.aspx?ElBullNo='+ElBullNo+'&AttachNo='+AttachNo,'查看附件','resizable=yes')
    }
    //-->
    </script>
    <body MS_POSITIONING="GridLayout" class="MainBody" scroll="yes">
    <form id="frmElBulletin" method="post" runat="server">
    <FONT face="宋体">
    <TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" cellSpacing="0" width="96%">
    <TR>
    <TD style="FONT-SIZE: 9pt">标&nbsp;&nbsp;&nbsp;&nbsp;题:&nbsp;&nbsp;&nbsp;<FONT color="red">
    <asp:Label id="lbSubject" runat="server"></asp:Label></FONT></TD>
    </TR>
    <TR>
    <TD style="FONT-SIZE: 9pt">发&nbsp;布&nbsp;者:&nbsp;&nbsp;&nbsp;
    <asp:Label id="lbAuthor" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;(时间:
    <asp:Label id="lbTime" runat="server"></asp:Label>)</TD>
    </TR>
    <TR>
    <TD style="FONT-SIZE: 9pt">信息分类:&nbsp;&nbsp;&nbsp;
    <asp:Label id="lbTypeName" runat="server">Label</asp:Label></TD>
    </TR>
    <TR>
    <TD style="FONT-SIZE: 9pt">
    <HR>
    公告内容:</TD>
    </TR>
    <TR class="TrOdd">
    <TD style="FONT-FAMILY: 宋体" width="96%">
    <TABLE id="Table2" cellSpacing="0" cellPadding="6" width="100%" align="center" border="0">
    <TR bgColor="#f0f0f0">
    <TD>
    <SPAN id="ShowSpan" runat="server" style="FONT-SIZE: 9pt"></SPAN>
    </TD>
    </TR>
    <tr>
    <td runat="server" id="tdHr">
    </td>
    </tr>
    </TABLE>
    </TD>
    </TR>
    <TR id="trAttach" runat="server">
    <TD id="tdAttach" runat="server" style="FONT-SIZE: 9pt"></TD>
    </TR>
    <TR>
    <TD align="right" style="FONT-SIZE: 9pt"><label style="cursor:hand" style="COLOR: #6600ff" onclick="window.close();">【关闭窗口】</label></TD>
    </TR>
    </TABLE>
    <BR>
    </form>
    </body>
    </HTML>
    客户端代码
      

  3.   

    我是想实现比如一个文本框吧!
    <asp:textbox id="asd" runat="server">
    它的客户端的鼠标移动事件是怎么实现的??