页面将值分配给注册的隐藏字段ClientScript [英] Assign value to Registered Hidden Field in page ClientScript

查看:135
本文介绍了页面将值分配给注册的隐藏字段ClientScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.net应用程序中使用Page.ClientScript.RegisterHiddenField(hf_Name,值),如何覆盖或后面分配一个新的价值在code相同的隐藏字段'hf_Name?

I am using Page.ClientScript.RegisterHiddenField("hf_Name",value) in an ASP.net application, how to override or assign a new value to the same Hidden Field 'hf_Name' in code behind?

推荐答案

RegisterHiddenField 不创建一个服务器端控制,它只是 创建一个普通的老<输入类型=隐藏名称=myhiddenField>

RegisterHiddenField doesn't create a server side control, it just creates a plain-old <input type="hidden" name="myhiddenField">

Page.FindControl(myhiddenField)将永远找不到的服务器端,甚至的document.getElementById(myhiddenField)会没事就客户方返回,因为只有名称,而不是ID分配。

Page.FindControl("myhiddenField") will never find anything on serverside and even document.getElementById("myhiddenField") will return nothing on clientside since only the name and not the id is assigned.

所以,如果你需要访问它在服务器端,你应该使用的 HiddenField 服务器控件或至少使用 HTML输入 类型=隐藏 =服务器

So if you need to access it on serverside, you should use a HiddenField server control or at least use a html-input type=hidden with runat="server".

这篇关于页面将值分配给注册的隐藏字段ClientScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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