protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ctrError.Visible = false; labelHost.Text = Resources.Register_NoneFound; textName.ToolTip = Resources.Register_EnterNameForThisDisplay; buttonRegister.Text = Resources.Register_Register; // get host from URL first string host = Request.ServerVariables["REMOTE_HOST"]; if (string.IsNullOrWhiteSpace(host)) { host = Request.ServerVariables["REMOTE_ADDR"]; } if (string.IsNullOrWhiteSpace(host)) { buttonRegister.Enabled = false; } else { labelHost.Text = host; buttonRegister.Enabled = true; } try { // list canvases listCanvas.AutoPostBack = false; foreach (Canvas canvas in Canvas.List) { ListItem list = new ListItem( canvas.Name, canvas.CanvasId.ToString() ); listCanvas.Items.Add(list); } // list locations listLocation.AutoPostBack = false; foreach (Location loc in Location.List()) { ListItem list = new ListItem( loc.Name, loc.LocationId.ToString() ); listLocation.Items.Add(list); } } catch (Exception ex) { ctrError.Title = Resources.Error; ctrError.Message = ex.Message; ctrError.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // get host from URL first string theHost = Request.QueryString["host"]; // otherwise, get display address if (string.IsNullOrEmpty(theHost)) { theHost = Request.ServerVariables["REMOTE_HOST"]; if (string.IsNullOrEmpty(theHost)) { theHost = Request.ServerVariables["REMOTE_ADDR"]; } } if (theHost != null) { labelHost.Text = theHost; } else { buttonRegister.Enabled = false; } try { // list canvases listCanvas.AutoPostBack = false; foreach (Canvas canvas in Canvas.List) { ListItem list = new ListItem( canvas.Name, canvas.CanvasId.ToString() ); listCanvas.Items.Add(list); } // list locations listLocation.AutoPostBack = false; foreach (Location loc in Location.List()) { ListItem list = new ListItem( loc.Name, loc.LocationId.ToString() ); listLocation.Items.Add(list); } } catch (Exception ex) { Response.Write(ex.Message); // TODO: error label } } }