|
-
Jul 14th, 2003, 12:20 AM
#1
Thread Starter
yay gay
Creating buttons at runtime
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
\m/  \m/
-
Jul 14th, 2003, 07:31 AM
#2
PowerPoster
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.
-
Jul 14th, 2003, 05:55 PM
#3
Thread Starter
yay gay
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?
\m/  \m/
-
Jul 15th, 2003, 11:43 AM
#4
PowerPoster
This should get you started:
Code:
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");
}
-
Jul 15th, 2003, 02:48 PM
#5
Thread Starter
yay gay
i dont get in that where i say which place in my label code is going to have the button
\m/  \m/
-
Jul 15th, 2003, 03:09 PM
#6
PowerPoster
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.
-
Jul 15th, 2003, 04:56 PM
#7
Thread Starter
yay gay
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.. ..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
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|