Accessing control created dynamically in code behind
i have 开发者_运维问答a link button which i have created dynamically and added it to a div i want to access this link button in some other function in code behind how to do this
ASP.NET tips: Golden rules for Dynamic Controls.
If you have defined your control properly(with id) you can access it without a problem in the next request. But...if you want to access it in the same request, it is not rendered yet, so you need to define your control as a private field in your code behind in order to be able to access it outside your initialization/addToDiv function...
Hope this helps
Marko
As you create it dynamically, you are able to keep reference to this control as your page protected/private member. And access control by this reference.
精彩评论