最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ASP.net(C#)實現(xiàn)簡易聊天室功能

 更新時間:2022年02月12日 08:50:42   作者:「已注銷」  
這篇文章主要為大家詳細介紹了ASP.net實現(xiàn)簡易聊天室功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了ASP.net(C#)實現(xiàn)簡易聊天室功能的具體代碼,供大家參考,具體內(nèi)容如下

1.搭建框架

<html >
<head>
? ? <title>聊天系統(tǒng)</title>
</head>
? ? <frameset rows="80%,20%" >
? ? ? ? ? <frameset cols="20%,80%">
? ? ? ? ? <frame src="Register.aspx" />
? ? ? ? ? ? ? ?<frame src="main.aspx" />?
? ? ? ? ? ? ? ? ? ? ?</frameset>
? ? ? ? ? ? ? ?<frame src="login.aspx"/>

? ? ? </frameset>

<body >
?
</body>
</html>

2.框架涉及三個頁面  

建立相應(yīng)的頁面布局:

1.login.asp

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class login : System.Web.UI.Page
{undefined
? ? protected void Page_Load(object sender, EventArgs e)
? ? {undefined

? ? }
? ? protected void LoginBtn_Click(object sender, EventArgs e)
? ? {undefined
? ? ? ? if (LoginID.Text.Trim() == string.Empty)
? ? ? ? {undefined
? ? ? ? ? ? Response.Write("<script>alert('請輸入用戶名!')</script>");
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? if (LoginPwd.Text!= "123456")
? ? ? ? {undefined
? ? ? ? ? ? Response.Write("<script>alert('密碼不正確,請重新輸入')</script>");
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? if (!IfLonined())
? ? ? ? {undefined
? ? ? ? ? ? Response.Write("<script>alert('用戶名已經(jīng)存在')</script>");
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? Session["username"] = LoginID.Text;
? ? ? ? if (Application["user"] == null)
? ? ? ? {undefined
? ? ? ? ? ? Application["user"] = Session["username"];
? ? ? ? }
? ? ? ? else {undefined
? ? ? ? ? ? Application["user"] += "," + Session["username"];

? ? ? ? }
? ? ? ? Response.Redirect("send.aspx");

? ? }
? ? protected bool IfLonined()
? ? {undefined
? ? ? ? Application.Lock();
? ? ? ? string users;
? ? ? ? string[]user;
? ? ? ? if (Application["user"]!=null)
? ? ? ? {undefined
? ? ? ? ? ? users = Application["user"].ToString();
? ? ? ? ? ? user = users.Split(',');
? ? ? ? ? ? foreach(string s in user)
? ? ? ? ? ? {undefined
? ? ? ? ? ? ? ? if(s==LoginID.Text.Trim().ToString())
? ? ? ? ? ? ? ? {undefined
? ? ? ? ? ? ? ? ? ? return false;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? Application.UnLock();
? ? ? ? return true;
? ? }
? ? protected void LoginPWD_TextChanged(object sender, EventArgs e)
? ? {undefined

}
}

2.Register.asp

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Register : System.Web.UI.Page
{undefined
? ? protected ArrayList ItemList = new ArrayList();
? ? protected void Page_Load(object sender, EventArgs e)
? ? {undefined
? ? ? ? Response.AddHeader("Refresh", "1");
? ? ? ? Application.Lock();
? ? ? ? string users;
? ? ? ? string[] user;
? ? ? ? if (Application["user"]!=null)
? ? ? ? {undefined
? ? ? ? ? ? users = Application["user"].ToString();
? ? ? ? ? ? user = users.Split(',');
? ? ? ? ? ? for(int i=user.Length-1;i>=0;i--)
? ? ? ? ? ? {undefined
? ? ? ? ? ? ? ? ItemList.Add(user[i].ToString());

? ? ? ? ? ? }
? ? ? ? ? ? UserList.DataSource = ItemList;
? ? ? ? ? ? UserList.DataBind();
? ? ? ? }
? ? ? ? Application.UnLock();
? ? }
? ? protected void UserList_SelectedIndexChanged(object sender, EventArgs e)
? ? {undefined

? ? }
}

3.send.asp

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class send : System.Web.UI.Page
{undefined
? ? protected void Page_Load(object sender, EventArgs e)
? ? {undefined
? ? ? ? if (Session["username"] != null)
? ? ? ? {undefined
? ? ? ? ? ? Username.Text = Session["username"].ToString() + "說:";
? ? ? ? }
? ? ? ? else
? ? ? ? {undefined
? ? ? ? ? ? Response.Redirect("login.aspx");
? ? ? ? }


? ? }
? ? protected void SendBtn_Click(object sender, EventArgs e)
? ? {undefined
? ? ? ? string message;
? ? ? ? message = "<font color='blue'>" + Session["username"].ToString() + "</font>說:";
? ? ? ? message += Message.Text;
? ? ? ? message += "(<i>" + DateTime.Now.ToString() + "</i>)";
? ? ? ? message += "<br>";
? ? ? ? Application.Lock();
? ? ? ? if (chk.Checked)
? ? ? ? ? ? Application["chatcontent"] = (string)Application["chatcontent"] + message + "<img src=image/00.gif>" + "<img src=image/01.gif>";
? ? ? ? else
? ? ? ? ? ? Application["chatcontent"] = (string)Application["chatcontent"] + message;
? ? ??
? ? ? ? Application.UnLock();
? ? ? ? Message.Text = null;
? ? }
? ? protected void LoginBtn_Click(object sender, EventArgs e)
? ? {undefined
? ? ? ? Response.Redirect("login.aspx");
? ? }
? ? protected void LoginOutBtn_Click(object sender, EventArgs e)
? ? {undefined
? ? ? ? Application.Lock();
? ? ? ? if (Application["user"] != null)
? ? ? ? {undefined
? ? ? ? ? ? string users;
? ? ? ? ? ? string[] user;
? ? ? ? ? ? users = Application["user"].ToString();
? ? ? ? ? ? Application["user"] = null;
? ? ? ? ? ? user = users.Split(',');
? ? ? ? ? ? foreach (string s in user)
? ? ? ? ? ? {undefined
? ? ? ? ? ? ? ? if (s != Session["username"].ToString())
? ? ? ? ? ? ? ? {undefined
? ? ? ? ? ? ? ? ? ? if (Application["user"] == null)
? ? ? ? ? ? ? ? ? ? {undefined
? ? ? ? ? ? ? ? ? ? ? ? Application["user"] = s;
? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? {undefined
? ? ? ? ? ? ? ? ? ? ? ? Application["uesr"] = Application["user"] + "," + s;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? if (Session["username"] != null)
? ? ? ? {undefined
? ? ? ? ? ? Session["username"] = null;
? ? ? ? }
? ? ? ? Application.UnLock();
? ? ? ? Response.Redirect("login.aspx");


? ? }
? ? protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
? ? {undefined

? ? }

}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • .NET Core中Object Pool的多種用法詳解

    .NET Core中Object Pool的多種用法詳解

    本文通過實例代碼給大家介紹了.NET Core中Object Pool的簡單使用 ,大概給大家提供了四種方法,每種方法都很經(jīng)典,需要的朋友可以參考下
    2018-09-09
  • Asp.net基于ajax和jquery-ui實現(xiàn)進度條

    Asp.net基于ajax和jquery-ui實現(xiàn)進度條

    這篇文章主要介紹了Asp.net基于ajax和jquery-ui實現(xiàn)進度條,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-12-12
  • asp.net中如何批量導(dǎo)出access某表內(nèi)容到word文檔

    asp.net中如何批量導(dǎo)出access某表內(nèi)容到word文檔

    最近有項目需求是這樣的,需要將某表中的每一條記錄中的某些內(nèi)容導(dǎo)出在一個word文檔中。下面小編就把我的解決辦法分享給大家,供大家參考
    2015-10-10
  • ASP.NET Core中間件設(shè)置教程(7)

    ASP.NET Core中間件設(shè)置教程(7)

    這篇文章主要為大家詳細介紹了ASP.NET Core中間件的設(shè)置教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • ASP.NET MVC實現(xiàn)多個按鈕提交的方法

    ASP.NET MVC實現(xiàn)多個按鈕提交的方法

    這篇文章主要為大家詳細介紹了ASP.NET MVC實現(xiàn)多個按鈕提交的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • 網(wǎng)頁(aspx)與用戶控件(ascx)交互邏輯處理實現(xiàn)

    網(wǎng)頁(aspx)與用戶控件(ascx)交互邏輯處理實現(xiàn)

    為了以后好維護,把幾個頁面(ASPX)相同的部分抽取放在一個用戶控件(ASCX)上,現(xiàn)在把邏輯分享下,感興趣的各位可以參考下哈
    2013-03-03
  • .Net Core 集成 Kafka的步驟

    .Net Core 集成 Kafka的步驟

    這篇文章主要介紹了.Net Core 集成 Kafka的實現(xiàn)步驟,幫助大家更好的理解和學(xué)習(xí)使用.net技術(shù),感興趣的朋友可以了解下
    2021-04-04
  • asp.net Web Services上傳和下載文件(完整代碼)

    asp.net Web Services上傳和下載文件(完整代碼)

    隨著Internet技術(shù)的發(fā)展和跨平臺需求的日益增加,Web Services的應(yīng)用越來越廣,我們不但需要通過Web Services傳遞字符串信息,而且需要傳遞二進制文件信息。
    2008-12-12
  • ASP.NET MVC分頁問題解決

    ASP.NET MVC分頁問題解決

    這篇文章主要為大家詳細介紹了ASP.NET MVC分頁問題的解決方法,Ajax.Pager分頁的使用注意事項,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • ASP.NET AJAX 4.0的模版編程(Template Programming)介紹

    ASP.NET AJAX 4.0的模版編程(Template Programming)介紹

    不過當我評估ASP.NET AJAX 4.0的時候,我確實被它的特征給震住了。新的特征完全專注于瀏覽器技術(shù),比如XHTML和javascript。 我非常欽佩ASP.NET AJAX小組。
    2009-07-07

最新評論

昭苏县| 古交市| 敦煌市| 靖安县| 城固县| 贡嘎县| 彭阳县| 大渡口区| 鄂温| 陕西省| 龙陵县| 监利县| 吉隆县| 墨江| 水富县| 呼伦贝尔市| 通榆县| 克山县| 综艺| 旺苍县| 洞头县| 新竹市| 襄城县| 通州区| 宜章县| 彭泽县| 丽江市| 修文县| 宁城县| 兴山县| 汶上县| 开阳县| 吴忠市| 垣曲县| 五河县| 漯河市| 青田县| 远安县| 勃利县| 淄博市| 洛阳市|