如何输入动态生成的文本框的文本框文本 [英] how can i get entered textboxes text of dynamically generated textboxes

查看:124
本文介绍了如何输入动态生成的文本框的文本框文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了动态文本框。我有该文本框的ID ...我想将文本框中输入的文本插入数据库..如何做到这一点???

解决方案

所有控件值存在于Request对象中。您可以使用控件名称(UniqueID)而不是id从Request对象获取值。语法如下:



  var  textBoxValue = Request [txtBox.UniqueID ]; 





如果这没有用,请告诉我。


这取决于哪里你正在创建控件。我知道的简单解决方案:内创建控件Page_PreInit 事件



Page_PreInit 事件将轻松渲染您的控件并存储控件的 ViewState

然后你可以使用以下代码轻松找到动态创建的控件:

 TextBox TextBox1 =(TextBox)Page.FindControl(  TextBox); 



如果在创建控件时需要更多帮助或指南,请参阅类似文章的链接:







- Amit

I have created dynamic textboxes. i have got id of that textbox...i want to insert text which entered in textbox into database..how to do that???

解决方案

All the control values are present in Request object. You can fetch value from Request object using control name (UniqueID) not id. Syntax is given below

var textBoxValue = Request[txtBox.UniqueID];



Please let me know if this does not help.


It depends on where you are creating the controls. Simple solution which I ever know : Create controls inside Page_PreInit Event.

Page_PreInit event will render your controls easily and store the ViewState of your controls.
Then you can easily find the controls created dynamically using the following code:

TextBox TextBox1= (TextBox)Page.FindControl("TextBox");


If you need little more help or guideline while creating the controls then refer the links for similar articles:




--Amit


这篇关于如何输入动态生成的文本框的文本框文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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