SHOWcode
2018年6月14日 星期四
C# PlaceHolder
protected void Page_Load(object sender, EventArgs e)
{
Label myLabel = new Label();
TextBox mytxt1 = new TextBox();
DropDownList dp01 = new DropDownList();
// Set the label's Text and ID properties.
myLabel.Text = "Label123";
myLabel.ID = "Label123";
PlaceHolder1.Controls.Add(myLabel);
// Add a spacer in the form of an HTML <br /> element.
PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
mytxt1.ID = "mytxt1";
mytxt1.Text = "";
PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
//dp01.DataBind();
dp01.Items.Insert(0, new ListItem("Select a store", ""));
dp01.Items.Insert(1, new ListItem("AAA", ""));
dp01.Items.Insert(2, new ListItem("BBB", ""));
PlaceHolder1.Controls.Add(mytxt1);
PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
PlaceHolder1.Controls.Add(dp01);
PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
//CheckBox
CheckBoxList ckL01 = new CheckBoxList();
ckL01.Items.Insert(0, new ListItem("please check point:", ""));
ckL01.Items.Insert(1, new ListItem("point 001", "point001"));
ckL01.Items.Insert(2, new ListItem("point 002", "point002"));
ckL01.Items.Insert(3, new ListItem("point 003", "point003"));
PlaceHolder1.Controls.Add(ckL01);
//botton
for (int i = 1; i <= 10; i++)
{
LinkButton olbtn = new LinkButton();
olbtn.ID = "lbtn" + i;
olbtn.Text = "測試按鈕" + i;
olbtn.Click += new EventHandler(lbtn_Click);
PlaceHolder1.Controls.Add(olbtn);
Label olab = new Label();
olab.Text = " | ";
PlaceHolder1.Controls.Add(olab);
}
}
protected void lbtn_Click(object sender, EventArgs e)
{
LinkButton lbtn = (LinkButton)sender;
Response.Write("按鈕事件觸發:" + lbtn.ID);
// Label123.Text = "成功";
}
訂閱:
張貼留言 (Atom)
Jenkins-mail
參考:http://www.linuxea.com/1767.html 前置作業略過~有空再補 Mailer Plugin post { success { emailext ( subject: &...
-
ASP.NET刷新頁面的六種方法 第一: private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToSt...
-
foreach (string fname in System.IO.Directory.GetFileSystemEntries(@"C:\Users\joshs")) { //if (fn...
沒有留言:
張貼留言