开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜