温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

asp.net简易留言板

发布时间:2020-08-13 12:43:27 来源:网络 阅读:2823 作者:zhou2228502811 栏目:编程语言

asp.net简易留言板

源代码:

<asp:DataList ID="DataList1" runat="server" BackColor="LightGoldenrodYellow"
       BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black"
       Height="16px" Width="848px">
       <AlternatingItemStyle BackColor="PaleGoldenrod" />
       <FooterStyle BackColor="Tan" />
       <HeaderStyle BackColor="Tan" Font-Bold="True" />
       <SelectedItemStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
       <ItemTemplate>      
                           <img src="p_w_picpath/1.jpg" height="40" width="40">
                           留言者: <%# Eval("username") %>
                           EMAIL: <%# Eval("email") %>
                           留言时间: <%# Eval("posttime")%> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:LinkButton
                               ID="LinkButton1" runat="server">回复留言</asp:LinkButton>
                           &nbsp;&nbsp;&nbsp;
                           <asp:LinkButton ID="LinkButton2" runat="server">删除留言</asp:LinkButton>
                           <br/><hr/>
                           留言内容: <%# Eval("contente")%> <br/><hr/>                

                           回复内容: <%# Eval("reply")%> <br/><hr/>  

       </ItemTemplate>
   </asp:DataList>

查看留言界面:

protected void Page_Load(object sender, EventArgs e)
   {
       string conn = "Data Source=.;Initial Catalog=Information;Integrated Security=True";
       SqlConnection con = new SqlConnection(conn);
       string sqlstr = "select*from Message";
       SqlDataAdapter ad = new SqlDataAdapter(sqlstr,con);
       DataSet ds = new DataSet();
       con.Open();
       ad.Fill(ds);
       con.Close();
       DataList1.DataSource = ds.Tables[0].DefaultView;
       DataList1.DataBind();
   }

asp.net简易留言板

留言界面:

using System.Data.SqlClient;
using System.Data;

protected void Button2_Click(object sender, EventArgs e)//取消留言
   {
       TextBox1.Text = "";
       TextBox2.Text = "";
       TextBox3.Text = "";
   }
   protected void Button1_Click(object sender, EventArgs e)//发送留言
   {
       string conn = "Data Source=.;Initial Catalog=Information;Integrated Security=True";
       SqlConnection con = new SqlConnection(conn);
       string sqlstr = "insert into Message(username,sex,email,contente,p_w_picpathadd)values('" + TextBox1.Text + "','" + RadioButtonList1.SelectedValue + "','" + TextBox2.Text + "','" + TextBox3.Text + "','3.jpg')";
       SqlDataAdapter ad = new SqlDataAdapter(sqlstr, con);
       DataSet ds = new DataSet();  
       ad.Fill(ds);
   }

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI