使用java脚本创建的动态控件在ASP.Net中的回发中消失 [英] Dynamic controls created using java script disappears on postback in ASP.Net
问题描述
嗨朋友们,
1.我使用java脚本添加了动态控件。这些控件在回发后消失。
我希望保留控件。
2.如何将自动回发属性设置为html文本框。
3.下一个问题是在回发后,控件的焦点丢失了。它也应保留。
不具体控制。它是一个动态控件。
例如:在for循环中创建了带有自动回发='true'的文本框。所有文本框都回发了。它应该保留动态控件,还要关注用户输入的确切控件
请建议我解决上述问题
谢谢
Hi friends,
1. I added dynamic controls using java script. Those controls disappears on post back.
I want the controls to be retained.
2. How to set auto postback property to html text box.
3. Next question is After post back the focus of the control is lost. It should also be retained.
Not specific control. It is a dynamic control.
For example: n text boxes with auto postback='true' are created in for loop. All the text box post backs. It should retain the dynamic controls, also focuses the exact control in which the user is typing
Kindly suggest me solutions for the above problems
Thanks
推荐答案
每次发生回发时,整个页面都会重新创建,而aspx或代码隐藏中的服务器端控件只能是可用的。如果你想维护使用javascript创建的控件,那么你可以使用两个选项之一,比如
- 使用updatepanel并更新页面的特定部分。不是整页。
- 其他维护隐藏变量所需的信息,用于通过javascript创建的控件,并在每次回发时创建控件
Everytime a postback occurs thae whole page get recreated menas the server side controls that are in aspx or at codebehind will only be vailable. If you want to maintain the controls created using javascript then you can use one of two options like
- Use updatepanel and update the specific part of the page. Not the whole page.
- Other maintain the required information in hidden variable for the controls created via javascript and create those controls on every postback
这篇关于使用java脚本创建的动态控件在ASP.Net中的回发中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!