コード例 #1
0
        protected void postMessageButton_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(messageTextBox.Text))
            {
                int?messageId = 0;
                int replyId   = 0;
                if (Request.QueryString["MessageId"] != null)
                {
                    messageId = Convert.ToInt32(Request.QueryString["MessageId"]);
                }
                else if (Request.QueryString["ReplyId"] != null)
                {
                    replyId = Convert.ToInt32(Request.QueryString["ReplyId"]);
                }

                using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext())
                {
                    if (messageId > 0)
                    {
                        dataContext.UpdateMessage(messageId, messageTextBox.Text);
                        Response.Redirect(string.Format("MessageDetail.aspx?MessageId={0}", messageId));
                    }
                    else if (replyId > 0)
                    {
                        dataContext.UpdateReply(replyId, messageTextBox.Text, ref messageId);
                        Response.Redirect(string.Format("MessageDetail.aspx?MessageId={0}", messageId.Value));
                    }
                }
            }
        }