⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shownews.aspx

📁 用C#,VB和SQLSERVER编写的远程教学程序
💻 ASPX
字号:
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>

<Script Language="VB" Runat="Server">
  '读取数据库数据,并连接数据源到 Repeater 控件

  
  Sub BindList()
    Dim strSQL As String


    '指定第一个 Repeater 控件的数据来
   strSQL = "Select 作者, 邮件帐号, 主题, 内容, 图标, 时间 From 讨论区 Where 编号=" & Request("Id") & " Order By 时间 Desc"
    Dim ConnString As String = "workstation id=SONGWEI;packet size=4096;user id=sa;password=sql;data source=SONGWEI;persist se" & _
        "curity info=False;initial catalog=vodweb"
    dim objCmd as new SqlDataAdapter(strSQL,ConnString)
    dim DS as new DataSet()
    objCmd.Fill(DS,"讨论区")
    showMainSubject.DataSource =DS
    '指定第二个 Repeater 控件的数据源    
    strSQL = "Select 作者, 邮件帐号, 主题, 内容, 图标, 时间 From 回复区 Where 原主题编号=" & Request("Id") & " Order By 时间 Desc"
    dim ConnString2 as string="workstation id=SONGWEI;packet size=4096;user id=sa;password=sql;data source=SONGWEI;persist se" & _
        "curity info=False;initial catalog=vodweb"
    dim objCmd2 as new SqlDataAdapter(strSQL,ConnString2)
    dim DS2 as new DataSet()
    objCmd2.Fill(DS2,"回复区")
    
    If DS2.Tables("回复区").Rows.Count > 0 Then showReply.DataSource = DS2
    
    '将数据源连接到网页中有指定数据源的控件
    Page.DataBind()
  End Sub
  
  Sub Page_Init(sender As Object, e As Eventargs)
      BindList()
  End Sub

  '将回复的留言加入【回复区】数据表
  Sub AddRecord(sender As Object, e As EventArgs)
    Dim objConn As New SqlConnection()
    objConn.ConnectionString = "workstation id=SONGWEI;packet size=4096;user id=sa;password=sql;data source=SONGWEI;persist se" & _
        "curity info=False;initial catalog=vodweb"
    objConn.Open()
    Dim strSQL As String
    strSQL = "Insert Into 回复区(原主题编号, 作者, 邮件帐号, 主题, 内容, 图标, 时间)" & _
             " Values (" & Request("Id") & ", '" & UserName.Text & "', '" & Email.Text & _
             "', '" & Subject.Text & "', '" & Content.Text & _
             "', '" & ImgList.SelectedItem.Value & "', '" & _
             FormatDateTime(System.DateTime.Now, DateFormat.ShortDate) & " " & _
             FormatDateTime(System.DateTime.Now, DateFormat.ShortTime) & "')"
    Dim objCmd As New SqlCommand(strSQL, objConn)
    objCmd.ExecuteNonQuery()
    objConn.Close()
    BindList()
  End Sub
</Script>
<Html>
  <Body>
    <Center><Img Src="image/title2.jpg"></Center>
    <Form Runat="Server" ID="Form1">
      <Asp:Repeater Runat="Server" Id="showMainSubject">
        <HeaderTemplate>
          <Table Width="650" CellPadding="5" CellSpacing="0">
            <Tr BgColor="#0084CA" Align="Center">
              <Td ColSpan="4">
                <Font Color="White">讨论主题</Font>
              </Td>
            </Tr>
        </HeaderTemplate>
        <ItemTemplate>
          <Tr>
            <Td RowSpan="2" Width="60">
              <Img Src="<%# Container.DataItem("图标") %>">
            </Td>
            <Td Width="120" BgColor="#FFFF00">
              作者:<A Href="mailto:<%# Container.DataItem("邮件帐号") %>">
                    <%# Container.DataItem("作者") %></A>
            </Td>
            <Td Width="350" BgColor="#FFFF00">
              主题:<%# Container.DataItem("主题") %>
            </Td>              
            <Td Width="120" BgColor="#FFFF00">
              时间:<%# Container.DataItem("时间") %>
            </Td>
          </Tr>
          <Tr>
            <Td ColSpan="3" BgColor="#FFFFCC">
              <%# Container.DataItem("内容") %>
            </Td>
          </Tr>
        </ItemTemplate>
        <FooterTemplate>
          </Table>
        </FooterTemplate>
      </Asp:Repeater>
      <Asp:Repeater Runat="Server" Id="showReply">
        <HeaderTemplate>
          <Table Width="650" CellPadding="5" CellSpacing="0">
            <Tr BgColor="#0084CA">
              <Td ColSpan="4" Align="Center">
                <Font Color="White">回复主题</Font>
              </Td>
            </Tr>
        </HeaderTemplate>
        <ItemTemplate>
          <Tr>
            <Td RowSpan="2" Width="60">
              <Img Src="<%# Container.DataItem("图标") %>">
            </Td>
            <Td Width="120" BgColor="#FFCC99">
              作者:<A Href="mailto:<%# Container.DataItem("邮件帐号") %>"><%# Container.DataItem("作者") %></A></Td>
            <Td Width="350" BgColor="#FFCC99">
              主题:<%# Container.DataItem("主题") %>
            </Td>
            <Td Width="120" BgColor="#FFCC99">
              时间:<%# Container.DataItem("时间") %>
            </Td>
          </Tr>
          <Tr>
            <Td ColSpan="3" BgColor="#FFFFCC">
              <%# Container.DataItem("内容") %>
            </Td>
          </Tr>
        </ItemTemplate>
        <FooterTemplate>
          </Table>
        </FooterTemplate>
      </Asp:Repeater>
      <Table Border="0" Width="650" Cellspacing="0" CellPadding="3">
        <Tr BgColor="#0084CA" Align="Center">
          <Td Colspan="2">
            <Font Color="#FFFFFF">请在此输入您的回复</Font>
          </Td>
        </Tr>
        <Tr BgColor="#D9F2FF">
          <Td Width="100">作    者:</Td>
          <Td Width="550"><Asp:TextBox Runat="Server" Id="UserName" /></Td>
        </Tr>
        <Tr BgColor="#D9F2FF">
          <Td Width="80">邮件帐号:</Td>
          <Td Width="520">
            <Asp:TextBox Runat="Server" Id="Email" Columns="40" />
          </Td>
        </Tr>
        <Tr BgColor="#D9F2FF">
          <Td Width="80">选择图标:</Td>
          <Td Width="520">
            <Asp:RadioButtonList Runat="Server" Id="ImgList" RepeatColumns="7"
                 RepeatDirection="Horizontal" RepeatLayout="Flow">
              <Asp:ListItem Text="<Img Src='image/img-1.gif'" Value="image/img-1.gif" Selected="True" />
              <Asp:ListItem Text="<Img Src='image/img-2.gif'" Value="image/img-2.gif" />
              <Asp:ListItem Text="<Img Src='image/img-3.gif'" Value="image/img-3.gif" />
              <Asp:ListItem Text="<Img Src='image/img-4.gif'" Value="image/img-4.gif" />
              <Asp:ListItem Text="<Img Src='image/img-5.gif'" Value="image/img-5.gif" />
              <Asp:ListItem Text="<Img Src='image/img-6.gif'" Value="image/img-6.gif" />
            </Asp:RadioButtonList>
          </Td>
        </Tr>
        <Tr BgColor="#D9F2FF">
          <Td Width="80">主    题:</Td>
          <Td Width="520">
            <Asp:TextBox Runat="Server" Id="Subject" Columns="40" />
          </Td>
        </Tr>
        <Tr BgColor="#D9F2FF">
          <Td Width="80">内    容:</Td>
          <Td Width="520">
            <Asp:TextBox Runat="Server" Id="Content" TextMode="Multiline"
                 Rows="4" Columns="42" />
          </Td>
        </Tr>
        <Tr>
          <Td Colspan="2" Height="40" Align="Center">
            <Asp:LinkButton Runat="Server" Text="张贴留言" OnClick="AddRecord" ID="Linkbutton1" NAME="Linkbutton1"/>   
            <A Href="NewsGroup.aspx">返回讨论列表</A>
          </Td>  
        </Tr>
      </Table>  
    </Form>
  </Body>
</Html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -