protected void Register_Click(object sender, EventArgs e)
        {
            if (textName.Text != "" &&
                labelHost.Text != "::1" &&
                listCanvas.SelectedIndex >= 0 &&
                listLocation.SelectedIndex >= 0
                )
            {
                try
                {
                    Display display = new Display()
                    {
                        Host       = labelHost.Text,
                        Name       = textName.Text,
                        CanvasId   = Convert.ToInt32(listCanvas.SelectedValue),
                        LocationId = Convert.ToInt32(listLocation.SelectedValue),
                    };

                    display.Register();

                    HttpContext.Current.Response.Redirect("default.aspx");
                }

                catch (Exception ex)
                {
                    Response.Write(ex.Message); // TODO: error label
                }
            }
        }
        protected void Register_Click(object sender, EventArgs e)
        {
            try
            {
                ctrError.Visible = false;

                if (string.IsNullOrWhiteSpace(textName.Text))
                {
                    throw new Exception(Resources.NameRequired);
                }

                int canvas = 0;
                Int32.TryParse(listCanvas.SelectedValue, out canvas);
                if (canvas <= 0)
                {
                    throw new Exception(Resources.CanvasRequired);
                }

                int location = 0;
                Int32.TryParse(listLocation.SelectedValue, out location);
                if (location <= 0)
                {
                    throw new Exception(Resources.LocationRequired);
                }

                Display display = new Display()
                {
                    Host       = labelHost.Text,
                    Name       = textName.Text,
                    CanvasId   = canvas,
                    LocationId = location,
                };

                display.Register();

                if (Display.AutoLoadMode == Models.DisplayAutoLoadModes.DisplayAutoLoadMode_Cookie)
                {
                    Response.Cookies["DisplayMonkey"]["DisplayId"] = display.DisplayId.ToString();
                    Response.Cookies["DisplayMonkey"].Expires      = new DateTime(2038, 1, 1);
                }

                Response.Redirect("default.aspx");
            }

            catch (Exception ex)
            {
                ctrError.Title   = Resources.Error;
                ctrError.Message = ex.Message;
                ctrError.DataBind();
                ctrError.Visible = true;
            }
        }
Example #3
0
        protected void Register_Click(object sender, EventArgs e)
        {
            if (textName.Text != "" &&
                labelHost.Text != "::1" &&
                listCanvas.SelectedIndex >= 0 &&
                listLocation.SelectedIndex >= 0
                )
            {
                try
                {
                    Display display = new Display()
                    {
                        Host = labelHost.Text,
                        Name = textName.Text,
                        CanvasId = Convert.ToInt32(listCanvas.SelectedValue),
                        LocationId = Convert.ToInt32(listLocation.SelectedValue),
                    };

                    display.Register();

                    HttpContext.Current.Response.Redirect("default.aspx");
                }

                catch (Exception ex)
                {
                    Response.Write(ex.Message);	// TODO: error label
                }
            }
        }