protected void Page_Load(object sender, EventArgs e) { 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"]); } if (!Page.IsPostBack) { using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext()) { if (messageId > 0) { List <SelectMessageByIdResult> result = dataContext.SelectMessageById(messageId).ToList(); messageTextBox.Text = result[0].Message; if (result[0].UserId != StoredData.User.UserId) { Response.Redirect("/Messages.aspx"); } } else if (replyId > 0) { List <SelectReplyByIdResult> selectReplies = dataContext.SelectReplyById(replyId).ToList(); messageTextBox.Text = selectReplies[0].Body; if (selectReplies[0].UserId != StoredData.User.UserId) { Response.Redirect("/Messages.aspx"); } } } } }