how to create dyanmically multiple color button
and get value of that in text box??
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
ArshadRank #2,492 · 564 reputationPosted Apr 12, 2011, 3:42 AM EDT
find the below code to generate the dynamically button in aspx page and handled the click event of that button.
Button btn = new Button();
btn.ID = "btnSubmit";
btn.Text = "Submit";
Page.Form.Controls.Add(btn);
btn.Click += new EventHandler(btn_Click);
void btn_Click(object sender, EventArgs e)
{
//Handled the click event.
}
Regards,
Arshad.
piyush sardhara177 reputationPosted Apr 12, 2011, 3:55 AM EDT
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 12, 2011, 4:24 AM EDT
try this Button [Buttonname] = new Button(); [Buttonname].ID = "btnInsert"; [Buttonname].Text = "Insert"; Page.Form.Controls.Add([Buttonname]); [Buttonname].BackColor = System.Drawing.Color.Red;Andrew FensterRank #983 · 2K reputationPosted Apr 12, 2011, 6:46 AM EDT
A placeholder is an empty, invisible box that you can insert things into. In your markup for the page, you position the placeholder control where you want your button to appear. In the code, you insert the control(s) into the placeholder.
CrishRank #1,486 · 1.1K reputationPosted Apr 13, 2011, 3:50 AM EDT
Button btn = new Button();
btn.ID = "btnSubmit";
btn.Text = "Submit";
Page.Form.Controls.Add(btn);
btn.Click += new EventHandler(btn_Click);