private void rtnInitialization() { HelloWorldLabel.Text = "My label"; UserInfoBoxControl userInfoBoxControl = (UserInfoBoxControl)LoadControl("~/UserInfoBoxControl.ascx"); userInfoBoxControl.UserName = "******"; userInfoBoxControl.UserAge = 78; userInfoBoxControl.UserCountry = "Spain"; phUserInfoBox.Controls.Add(userInfoBoxControl); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("SELECT BusinessEntityId, FirstName FROM Person.Person")) { cmd.CommandType = CommandType.Text; cmd.Connection = connection; connection.Open(); ddlperson.DataSource = cmd.ExecuteReader(); ddlperson.DataTextField = "FirstName"; ddlperson.DataValueField = "BusinessEntityId"; ddlperson.DataBind(); } connection.Close(); } string sql = "SELECT Top 10 Persontype, FirstName,LastName from Person.Person"; GridView1.DataSource = this.GetData(sql); GridView1.DataBind(); // phUserInfoBox.Controls.Add(LoadControl("~/UserInfoBoxControl.ascx")); }
protected void onClick_accept(object sender, EventArgs e) { OleDbDataReader reader; connection = new OleDbConnection(path); connection.Open(); cmd = new OleDbCommand("INSERT INTO tblProfiles (user_name, user_password, first_name, last_name, gender, dob, street_address, province, country, zip) " + "VALUES ('" + username + "', '" + userPassword + "', '" + firstName + "', '" + lastName + "', '" + gender + "', '" + dob + "', '" + streetAddress + "', '" + province + "', '" + country + "', '" + zip + "')", connection); reader = cmd.ExecuteReader(); while (reader.Read()) { UserInfoBoxControl MyUserInfoBoxControl = (UserInfoBoxControl)LoadControl("UserInfoBoxControl.ascx"); phUserInfoBox.Controls.Add(MyUserInfoBoxControl); MyUserInfoBoxControl.UserName = reader.GetString(0); MyUserInfoBoxControl.UserPassword = reader.GetString(1); MyUserInfoBoxControl.FirstName = reader.GetString(2); MyUserInfoBoxControl.LastName = reader.GetString(3); MyUserInfoBoxControl.Gender = reader.GetString(4); MyUserInfoBoxControl.DOB = reader.GetString(5); MyUserInfoBoxControl.StreetAddress = reader.GetString(6); MyUserInfoBoxControl.Province = reader.GetString(7); MyUserInfoBoxControl.Country = reader.GetString(8); MyUserInfoBoxControl.Zip = reader.GetString(9); } connection.Close(); Server.Transfer("index.aspx"); }
protected void Page_Load(object sender, EventArgs e) { HelloWorldLabel.Text = "Hello, !" + TextInput.Text; UserInfoBoxControl userInfoBoxControl = (UserInfoBoxControl)LoadControl("~/UserInfoBoxControl.ascx"); userInfoBoxControl.UserName = "******"; userInfoBoxControl.UserAge = 78; userInfoBoxControl.UserCountry = "Spain"; phUserInfoBox.Controls.Add(userInfoBoxControl); }
protected void Page_Load(object sender, EventArgs e) { BodyTag = (HtmlGenericControl)Master.FindControl("BodyTag"); UserInfoBoxControl userInfoBoxControl = (UserInfoBoxControl)LoadControl("~/UserInfoBoxControl.ascx"); userInfoBoxControl.UserName = "******"; userInfoBoxControl.UserAge = 78; userInfoBoxControl.UserCountry = "Spain"; phUserInfoBox.Controls.Add(userInfoBoxControl); HelloWorldLabel.Text = "Hello, " + TextInput.Text; if (Request.Cookies["BackgroundColor"] != null) { ColorSelector.SelectedValue = Request.Cookies["BackgroundColor"].Value; BodyTag.Style["background-color"] = ColorSelector.SelectedValue; } }