Skip to content

Instantly share code, notes, and snippets.

@dz0
Created October 6, 2016 18:36
Show Gist options
  • Select an option

  • Save dz0/cce2d22ff4818536869002e9b3b7793e to your computer and use it in GitHub Desktop.

Select an option

Save dz0/cce2d22ff4818536869002e9b3b7793e to your computer and use it in GitHub Desktop.
//WebForm1.aspx:
/*
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3_chat.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Chat</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&nbsp;<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
</form>
</body>
</html>
*/
//WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication3_chat
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = System.IO.File.ReadAllText("c:\\tmp\\Chat.txt");
}
protected void Button1_Click(object sender, EventArgs e)
{
string input = TextBox1.Text;
System.IO.File.AppendAllText("c:\\tmp\\Chat.txt", input+ "<br>");
Label1.Text = System.IO.File.ReadAllText("c:\\tmp\\Chat.txt");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment