Beispiel #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Joke joke = JokeFactory.Create();
                joke.Title      = txtTitle.Text;
                joke.Teaser     = txtTeaser.Text;
                joke.JokeText   = txtJokeText.Text;
                joke.CategoryId = Convert.ToInt32(ddlCategory.SelectedValue);
                joke.JokeId     = Convert.ToInt16(Request.QueryString["jID"]);
                joke.TimeStamp  = Session["timestamp"];
                if (chkFeatured.Checked == true)
                {
                    joke.IsFeatured = true;
                }
                else
                {
                    joke.IsFeatured = false;
                }


                CUDMethods.Update(joke);
                lblMessage.Text      = "Joke has been updated!";
                Session["timestamp"] = joke.TimeStamp;
                //Clear();
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Beispiel #2
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         Joke joke = JokeFactory.Create();
         joke.Title      = txtTitle.Text;
         joke.Teaser     = txtTeaser.Text;
         joke.JokeText   = txtJokeText.Text;
         joke.CategoryId = Convert.ToInt32(ddlCategory.SelectedValue);
         if (chkFeatured.Checked == true)
         {
             joke.IsFeatured = true;
         }
         else
         {
             joke.IsFeatured = false;
         }
         CUDMethods.Add(joke);
         lblMessage.Text = "Joke has been added!";
         Clear();
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
Beispiel #3
0
        private void bindJokeRepeater(string jokeId)
        {
            Joke        joke    = JokeFactory.Create(Convert.ToInt32(jokeId));
            List <Joke> lstJoke = new List <Joke>();

            lstJoke.Add(joke);
            rptJokes.DataSource = lstJoke;
            rptJokes.DataBind();
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlCategory.DataTextField  = "categoryName";
                ddlCategory.DataValueField = "categoryID";

                string jokeId = Request.QueryString["jID"];

                if (!String.IsNullOrEmpty(jokeId))
                {
                    Joke joke = JokeFactory.Create(Convert.ToInt32(jokeId));
                    Session["timestamp"] = joke.TimeStamp;
                    bindJokeInformation(joke);
                    bindDropDownList(joke);
                }
                else
                {
                    Response.Redirect("Default.aspx");
                }
            }
        }