Beispiel #1
0
        protected void ButtonChooseRecipient_Click(object sender, EventArgs e)
        {
            int    otherid   = -1;
            int    currentid = CurrentUser.GetUserId();
            string username;

            // Validate Username
            if (string.IsNullOrWhiteSpace(ReceiverId.Text))
            {
                Msg.Text = "Username entered is empty";
                return;
            }
            else
            {
                otherid  = Authenticate.ConvertUsernameToId(ReceiverId.Text);
                username = ReceiverId.Text;
            }

            // Validate UserID exists
            if (otherid == -1)
            {
                Msg.Text = "No recipient by this username was found";
                return;
            }
            else if (otherid == currentid)
            {
                Msg.Text = "You cannot start a conversation with yourself!";
                return;
            }
            else if (otherid != currentid && otherid > 0)
            {
                ViewState["thisParty"]  = CurrentUser.GetUserId();
                ViewState["otherParty"] = otherid;

                ToggleWindows();
                LblRecipient.Text       = Authenticate.ConvertIdToUsername(otherid);
                ChatRepeater.DataSource = RetrieveMessages(otherid);
                ChatRepeater.DataBind();
                return;
            }
        }
Beispiel #2
0
        protected void ChatRepeater_Load(object sender, EventArgs e)
        {
            base.OnLoad(e);
            int otherid;

            if (ViewState["otherParty"] != null)
            {
                otherid = (int)ViewState["otherParty"];
            }
            else
            {
                otherid = -1;
            }

            ChatRepeater.DataSource = RetrieveMessages(otherid);
            ChatRepeater.DataBind();

            if (ChatWindow.Visible)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Javascript", "javascript:updateScroll();", true);
            }
        }