开发者

create dynamic asp.net button in code behind but render in specific place on aspx page

开发者 https://www.devze.com 2023-03-20 20:15 出处:网络
Creating a dynamic button in code behind as: Dim b As Button = New Button() b.Text = \"Some Dynamic Text Here\"

Creating a dynamic button in code behind as:

Dim b As Button = New Button()
b.Text = "Some Dynamic Text Here"
b.PostBackUrl = "some_page.asx"

I want to be able to render that in a specific location on an aspx page.

In aspx page, I want to do:

<td>
<%
If (specific condition) Then
    'render that specific button here <---------
Else
    'render something else
End If 
%>
</td>

1 - I know of being able to do a

Page.Form.Controls.Add(dynamic button here)

but I can not add it into a specific place on the page (not even with CSS because the button will go into a table -- the table has a column of numbers where if non zero, a button will show that crosspage postback to show drilldowned items)开发者_JAVA技巧


You can put a placeholder where you want the button to be

<asp:PlaceHolder ID="placeHolder" runat="server"></asp:PlaceHolder>

And add the button in the code

If (specific condition) Then   
    placeHolder.Controls.Add(b) 
0

精彩评论

暂无评论...
验证码 换一张
取 消