473,789 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting hidden input control programmaticall y

Hi all,

I have a loop in my code which builds the controls on the page.

I at one stage need to add some hidden input controls dynamically, I have
achieved this, and I have set their properties, however, there seems to be
one that I cannot set - ie, Name..

My code looks like this:

' loop starts here

' set hidden control properties
hidDataItem.Att ributes("name") = intLoop
hidDataItem.Att ributes("id") =
m_params.GetPar ameterByIndex(i ntLoop).m_objec tName
hidDataItem.Att ributes("value" ) =
m_params.GetPar ameterByIndex(i ntLoop).m_query StringData
panelForm.Contr ols.Add(hidData Item)

' loop ends here

The results look like this:

<input name="_ctl1" type="hidden" id="hidRID" value="B6xky" /><input
name="_ctl10" type="hidden" id="hidHospital " value="BRI" />

Whilst the ID and Value properties are the only ones I'll be interested in
later, ie, when the form is submitted, its making me wonder why it is that I
am unable to set the name property.

I've tried having

"name" = m_params.GetPar ameterByIndex(i ntLoop).m_objec tName

when it didnt work I thought - hmm, maybe it doesn't like having an ID and a
Name that are equal (odd I know - as it'll only render HTML) but I changed
it anyway....so currently set to intLoop...

Its almost as if the 'name' property is written before you get to set
anything and thus defaults to _ctl1, _ctl2 and so on..

Any info on this one would be appreciated, as I say I can still get the form
to do what I need it to do - so no real biggy - I'd just like to understand
'why' it doesn't let me set its value.

Thanks in advance.

Regards

Rob
Nov 18 '05 #1
1 2379
its much simpler to use RegisterHiddenF ield for this purpose.

anyway your problem is that you are setting the attributes instead of the
control property Id. To implement postback, the control makes the name
attribute match its ID (serverside), so you can not override the name. you
can override the id attribute, because it is not posted back, and has no
effect on server processing.
-- bruce (sqlwork.com)
"Rob Meade" <ro**********@N OSPAMubht.swest .nhs.uk> wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l...
Hi all,

I have a loop in my code which builds the controls on the page.

I at one stage need to add some hidden input controls dynamically, I have
achieved this, and I have set their properties, however, there seems to be
one that I cannot set - ie, Name..

My code looks like this:

' loop starts here

' set hidden control properties
hidDataItem.Att ributes("name") = intLoop
hidDataItem.Att ributes("id") =
m_params.GetPar ameterByIndex(i ntLoop).m_objec tName
hidDataItem.Att ributes("value" ) =
m_params.GetPar ameterByIndex(i ntLoop).m_query StringData
panelForm.Contr ols.Add(hidData Item)

' loop ends here

The results look like this:

<input name="_ctl1" type="hidden" id="hidRID" value="B6xky" /><input
name="_ctl10" type="hidden" id="hidHospital " value="BRI" />

Whilst the ID and Value properties are the only ones I'll be interested in
later, ie, when the form is submitted, its making me wonder why it is that I am unable to set the name property.

I've tried having

"name" = m_params.GetPar ameterByIndex(i ntLoop).m_objec tName

when it didnt work I thought - hmm, maybe it doesn't like having an ID and a Name that are equal (odd I know - as it'll only render HTML) but I changed
it anyway....so currently set to intLoop...

Its almost as if the 'name' property is written before you get to set
anything and thus defaults to _ctl1, _ctl2 and so on..

Any info on this one would be appreciated, as I say I can still get the form to do what I need it to do - so no real biggy - I'd just like to understand 'why' it doesn't let me set its value.

Thanks in advance.

Regards

Rob

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2259
by: J Krugman | last post by:
I have a form with a couple of submit buttons, plus a "pseudolink" that is also supposed to submit the form; the submitted form data feeds to a CGI script. The two submit buttons have the name "go_for_it", so that when the form is submitted, the CGI script looks for the value of the CGI parameter "go_for_it". I want the pseudolink to set the value of this CGI parameter prior to submitting the form, but I can't get it to work. Here's the...
18
18420
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
3
1267
by: Andy Fish | last post by:
Hi, I want to generate a value with javascript and include it in the form postback for a web form. based on my previous web development experience, I think I need an <input type=hidden> on the page. However, to fit in properly with the web forms paradigm, I would like this to be a proper asp.net server side control rather than just generating it in the HTML.
6
2297
by: Andre Ranieri | last post by:
I'm trying to create a login page for customers to log into our corporate website, our presidents naturally wants the user and password fields to populate from a cookie so the customer doesn't have to type their credentials every time, this seems like a pretty common thing. However, when I try to populate the password HTML textbox from the cookie, the textbox remains blank. However, if I try this from an equivalent web control, the...
14
3487
by: Paul | last post by:
I want to set the page title and/or a form hidden field programatically through ASP.Net. I do not want to use something like... <% sTitle ="My Title" %> <html><title><%=sTitle%></title>..... I want to completely seperate the code from presentation. I would like to do the same thing for a value of a hidden form field but
4
11719
by: WB | last post by:
Hi, I need to validate a hidden input in my webform to ensure that it's got value. The controls look something like this: <input id="HidSelectedStates" type="hidden" runat="server" /><br /><br /> <asp:Button ID="BtnSubmit" runat="server" OnClick="BtnSubmit_Click" Text="Submit" ValidationGroup="submitStates" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
1
6510
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
11
7426
by: newbie | last post by:
i have a form in which a hidden field (initial value as '0', and my javascript set it to '1' when an event is trigged). In the same form, i have a reset field. But I realized that the hidden field is not reset to '0' when i push the reset button. If I simply change the node from "<input type="hidden" id='IsChanged' value='0'>" to "<input type="text" id='IsChanged' value='0'>" Everything is working as expected (the value is reset to '0'...
2
2562
by: corykendall | last post by:
Here is my code: ... Setting hidden input to: <dsp:valueof param="tabname"/> <input name="tabname" type="hidden" value='<dsp:valueof param="tabname"/>'/> </dsp:form> hidden input set to:<script language="JavaScript"> document.write(document.getElementById("tab_switchRefreshForm").elements.tabname.value);</script><BR/> Now when I'm in IE, everything works fine and the output is as follows:
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9984
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.