如何在asp.net中获取控件值 [英] how to get the controls values in asp.net

查看:299
本文介绍了如何在asp.net中获取控件值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在研究如何为ASP网格创建动态行,并且该行包含文本框和一些其他控件..这里的问题是,当我单击按钮时,新行将添加到网格中,但是当我希望保存页面时获得回发和新添加的行销毁器.所以有什么方法可以获取这些控件的值...



提前谢谢...

Seshu

Hi All,

I am working on how to create dynamic row to an asp grid and that row contains text box and some other controls.. Here my question is when i click on button a new row is added to the grid but when i wish to save the page get postback and the newly added row disapers . so is there any way to get these controls values ...



Thanks in advance...

Seshu

推荐答案

您遇到的问题是,仅在page_load之前恢复了视图状态.在该事件之后添加的所有内容都不会具有viewstate.并且您添加的所有控件都需要在每次回发中添加.一种解决方案是在页面上隐藏控件,并使用javascript在该控件中存储动态控件的详细信息(例如XML).隐藏的控件将在aspx中定义,因此它的viewstate始终会恢复,然后您可以每次使用此数据重新创建这些控件.网络上还提供了其他解决方案,但所有解决方案都涉及在页面加载事件之前恢复所有动态控件.
The problem you have is that viewstate is restored just BEFORE page_load. Anything you add after that event, will not have viewstate. And any controls you add, need to be added on EVERY postback. One solution is to have a hidden control on your page, and use javascript to store details of your dynamic controls, perhaps as XML, in that control. Your hidden control will be defined in your aspx, so it''s viewstate is always restored, then you can use this data to recreate those controls every time. There''s other solutions offered on the web, but they will all involve restoring all your dynamic controls BEFORE the page load event.


这篇关于如何在asp.net中获取控件值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆