Click to See Complete Forum and Search --> : Creating buttons at runtime
PT Exorcist
Jul 14th, 2003, 12:20 AM
i have a asp.net label that will put a lot of code into my page..this is the best way i saw to make this job..but i wanna put some buttons in there how do i add them to the label in html code so i can use them later? also i dont wanna javascript ones, i wanna asp.net ones that i can use with events etc
Lethal
Jul 14th, 2003, 07:31 AM
I would add a placeholder control to easy the positioning of the buttons and then all you need to do is create the buttons, wire-up the events, and add the button(s) to the placeholder's controls collection. Also, note that you will have to re-create the objects on every postback.
PT Exorcist
Jul 14th, 2003, 05:55 PM
could u give an example? for example i have this:
Label1.Text = "<br></br>";
i want it to be between the two br tags..how would i do it?
Lethal
Jul 15th, 2003, 11:43 AM
This should get you started:
private void Page_Load(object sender, System.EventArgs e) {
Button SayHelloButton = new Button();
SayHelloButton.Click += new EventHandler(Button1_Click);
ButtonContainer.Controls.Add(SayHelloButton);
}
private void Button1_Click(object sender, System.EventArgs e) {
Response.Write("Hello World");
}
PT Exorcist
Jul 15th, 2003, 02:48 PM
i dont get in that where i say which place in my label code is going to have the button :confused:
Lethal
Jul 15th, 2003, 03:09 PM
What exactly are you trying to accomplish? I dont understand why you want to add a button inside of a label. Draw me a picture and I'll see what I can do.
PT Exorcist
Jul 15th, 2003, 04:56 PM
the label will contain code like
label1.text = "<br>hi</br><img src="www........">HERE I WANT A BUTTON<br>hi</br>";
i hope this is self explanatory..:rolleyes:..and no i cant put a label, an image control a button and another label..because it has a lot more code and is always repeating..and as i am not connecting to a database i cant use the datalist control
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.