如何检索在masterpage的contentplaceholder中动态创建的文本框的值 [英] how to retrieve the value of the textboxes created dynamically within the contentplaceholder in masterpage

查看:72
本文介绍了如何检索在masterpage的contentplaceholder中动态创建的文本框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在后面的代码中创建了动态文本框,

I have created dynamic textboxes in code behind,

While rdrAs.Read
strFields = strFields & "field" & rdrAs("AttributePos") & ","
strAssetTable = strAssetTable & "<tr><td>" & rdrAs("Attributename") & "</td><td><input type='text' ID='field" & rdrAs("AttributePos") & "'" & "><td></tr>"
End While



aspx页面具有母版页,而母版页又包含contentplaceholder.

文本框-field1,field2等已在运行时中创建.
我想知道如何通过单击事件访问文本框的值.

帮忙.
在此先感谢



The aspx page has a master page which in turn contains the contentplaceholder.

Textboxes - field1,field2 etc has been created in runtime.
I want to know how to access the value of the textbox by click event.

kinldy help.
Thanks in advance

推荐答案

输入类型=文本" ID =字段"& rdrAs("AttributePos")&'' &">< td>
1.您要创建的是html客户端控件,而不是服务器端控件.因此将永远无法访问.

2.为什么要创建HTML?让.NET为您做到这一点.创建一个文本框服务器控件,分配必要的详细信息(Id,值,css),然后将其添加到占位符/面板.这可以动态完成,并且代码将类似于您尝试的内容,而不是html.
示例代码如下:
input type=''text'' ID=''field" & rdrAs("AttributePos") & "''" & "><td>
1. What you are creating is an html-client side controls and not server side controls. Thus will never be accessible.

2. Why are you creating an HTML? Let .NET do that for you. Create a textbox server control, assign necessardy details (Id, value, css) and then add it to the placeholder/panel. This can be done dynamically and code would be similar to what you are trying just not html.
Sample code would be something like:
Dim tb As New TextBox
tb.ID = "field" & rdrAs("AttributePos")
'
' anything else needed here
'
 
myPanel.Add(tb)


这篇关于如何检索在masterpage的contentplaceholder中动态创建的文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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