Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HtmlGenericControl _nc = (HtmlGenericControl)Master.FindControl("navForum");
            _nc.Attributes.Add("class", "active");

            String _forumId = Request.QueryString["forumId"];
            if (!String.IsNullOrEmpty(_forumId))
            {
                ViewState.Add("forumId", _forumId);
                Forum _frm = new Forum(this.ConnectionString);
                _frm.LitePopulate(ViewState["forumId"], false);

                txt_Desc.Text = _frm.Description;
                txt_Title.Text = _frm.Title;
                ch_Active.Checked = _frm.Active;
                lbl_Header.Text = String.Format("{0}", _frm.Title);
            }
            else
            {
                lbl_Header.Text = "Add Forum";
            }

        }
    }
Пример #2
0
    protected void Save_Click(Object sender, EventArgs e)
    {
        if (IsValid)
        {
            Forum _frm = new Forum(this.ConnectionString);
            if (ViewState["forumId"] != null)
            {
                _frm.LitePopulate(ViewState["forumId"], false);
            }

            _frm.Title = txt_Title.Text;
            _frm.Description = txt_Desc.Text;

            _frm.Active = ch_Active.Checked;

            if (_frm.Save())
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('Record has been updated successfully.');self.location = 'Forums.aspx';", true);
            }
            else
            {
                lbl_Error.Text = "An unexpected error has occurred. Please try again.";
                lbl_Error.Visible = true;
            }
        }
    }
Пример #3
0
    protected void Updade_Click(object sender, EventArgs e)
    {
        Forum _st = null;
        foreach (GridViewRow I in gv_Forum.Rows)
        {
            Label _id = (Label)I.FindControl("lbl_Id");
            if (_id != null)
            {

                TextBox _sort = (TextBox)I.FindControl("txt_Sort");
                if (Regex.IsMatch(_sort.Text, @"\d+", RegexOptions.IgnoreCase))
                {
                    _st = new Forum(this.ConnectionString);
                    _st.LitePopulate(_id.Text, false);
                    _st.Sort = Convert.ToInt32(_sort.Text);
                    _st.Save();
                }

            }
        }
        BindData();
    }