tags:

views:

164

answers:

3

can i send a server control from the aspx.cs page

A: 

add a label to your form

in your code behind file [cs file]

label1.Text="<a href='your url'>LinkButton</a>";
Searock
I fail to see how this would help in creating a LinkButton control instance in the page?
Fredrik Mörk
i have edited my code
Searock
Adding a control declaration to the Text property like that isn't going to do anything except render out the declaration as text on the page.
Zhaph - Ben Duguid
well have you tried it ?
Searock
have a look at this pagehttp://www.maconstateit.net/tutorials/ASPNET1/ASPNET03/aspnet03-01.aspx
Searock
ok sorry works only with html controlsit cant render server controls
Searock
@Searock: Zhaph - Ben Duguid is quite correct. Try to understand what is happening here... When you insert HTML markup into the text value of a control, it is rendered on the client as-is. It does not become a part of the Page controls collection. On a side note, I wanted to give you a vote just for mentioning David Adams' tutorials (one of my favourites!), but as you can see, your answer is incorrect.
Cerebrus
+5  A: 

If by "send" you mean "create", then you can do it easily by adding the dynamically created control to a container such as the Page or a Panel:

LinkButton lnk1 = new LinkButton();
// Set any required properties.
...

// Add the control to the container.
Panel1.Controls.Add(lnk1);

The LinkButton will be rendered at the client as expected.

Cerebrus
A: 

You do it directly also.

Pages.Controls.Add(yourcontrolpathhere)

jalpesh