思归大侠:如何才能通过自定义服务器控件中的一个方法把页面中html文本框值取出来!

stoway 2003-09-06 10:34:20
上次的问题如下:
http://expert.csdn.net/Expert/topic/2229/2229406.xml?temp=.8592188
按你的方法已经解决了,然后我想在用户修改文本框的值后通过button调用自定义服务器控件中的一个方法将值保存到数据库中,但我用Page.Request.Params[Clientid].toString()取值时总是说'未将对象引用设置到对象的实例',是不是不能用此办法来获取,Waiting.....(再次感谢!)
...全文
49 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
stoway 2003-09-07
  • 打赏
  • 举报
回复
如果我想动态分配文本框的id,那么应该怎么取才能取到呢
stoway 2003-09-07
  • 打赏
  • 举报
回复
太感谢了,这两次通过你的指点已经解决了,再次感谢!!!
saucer 2003-09-07
  • 打赏
  • 举报
回复
if you are outputting html yourself, then set its name field besides the id field:
(aaa can be same as bbbb)
"<input type=text id=aaa name=bbbb value=123>",

then on the server side, you do Request.Form["bbbb"]. The reason to use UniqueID/ClientID is that the system will always genereate unique id/names. For example, if you put two copies of your controls, with ClientID/UniqueID, their id/name will be different on the client side, but if you are outputting html yourself, they end up with same id/name, and that can cause problems when you are doing client side scripting or when you are retrieving the data on the server side
saucer 2003-09-06
  • 打赏
  • 举报
回复
try

Page.Request.Params[UniqueID]

ClientID --> id
UniqueID --> name --> goes into Request.Form

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧