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"); } } } } }
protected void Page_Load(object sender, EventArgs e) { int messageId = Convert.ToInt32(Request.QueryString["MessageId"]); if (!Page.IsPostBack) { using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext()) { List <SelectMessageByIdResult> result = dataContext.SelectMessageById(messageId).ToList(); if (result[0].DivisionId != StoredData.User.Division) { Response.Redirect(WebConfigurationManager.AppSettings["MessagePath"]); } messageSourceRepeater.DataSource = result; messageSourceRepeater.DataBind(); if (result[0].EmailPost.Value) { ViewState["PostOwnerEmail"] = result[0].EmailId; } if (result[0].Message.Length < 27) { ViewState["Subject"] = result[0].Message; } else { ViewState["Subject"] = result[0].Message.Substring(0, 25) + ".."; } List <SelectRepliesResult> selectReplies = dataContext.SelectReplies(messageId).ToList(); messageRepeater.DataSource = selectReplies; messageRepeater.DataBind(); } } }