开发者

Accessing control created dynamically in code behind

开发者 https://www.devze.com 2023-01-09 14:52 出处:网络
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 thisASP.NET tips: Golden ru

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.

0

精彩评论

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