473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

RegisterHiddenField does not work inside .ascx components

Hi all,

I am writing a .cs component that sets RegisterHiddenField on the
server side and generates javascript to execute on the client side.

It works when the component is directly in the page, but not when it
is inside an ascx. In the source code of the page, I can see that the
ascx adds an prefix before the ID of the hidden field. This kind of
thing is no problem when you are using javascript on objects such as
buttons, that have a representation on the server side, so you can
write Button1.ClientId . But RegisterHiddenField does not rest on any
objects on the server side, so I don't see how I can find out what the
client ID is going to be.

Here is an exemple of registering on the server side:
this.Page.RegisterHiddenField("visibleElement", "0") ;

Here is an exemple of using on the client side side:
function showHide(str)
{
idOfElementToHide = document.getElementById(visibleElement).value;
document.getElementById(idOfElementToHide ).style.display= 'none';
....
Here is what I get in the source code when the component is used
directly in the page:

<input name="visibleElement" id="domainsToOpen" type="hidden" />

here is what I see when the component is used inside a .ascx
component:
<input name="TabControl1:_ctl1:visibleElement"
id="TabControl1__ctl1_visibleElement" type="hidden" />
Nov 17 '05 #1
0 1447

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

Similar topics

1
by: Matthew Wieder | last post by:
Hi - I wanted to capture the enter button on a form since I have a datagrid with the first column being a delete button and if someone hits enter it deletes the first record. I coded: private...
4
by: Erik Cruz | last post by:
Hi. I am creating a custom control that uses the RegisterHiddenField method to insert a hidden field on a page. When I tried to see the value of the hidden field on a trace, I noticed that it...
0
by: Dave | last post by:
Are there any known restrictions on where Page.RegisterHiddenField will work? It seems to only work in the Page_Load event...My code below fails to render it in the page's source I would like...
1
by: Kepler | last post by:
I have a custom control that is thrown onto a UserControl that is thrown onto a WebForm. Basically, I've got a scenario where if my UserControl sets an attribute on the custom control in the ascx,...
1
by: Pete Mahoney | last post by:
I have a datagrid with a button column that displays some partner info. i.e. PartnerId, PartnerName ... The button column has a button that when the user clicks it they are redirected or...
2
by: ashish | last post by:
If i want to add a hidden field on the page, how can i check whether that hidden field exists ? for example if i do If Page.FindControl("myhiddenfield") Is Nothing Then...
2
by: Fabiano | last post by:
Please, i have a ASPX that contains two usercontrols, TOP.ASCX and CENTER.ASCX. The first one has a dropdown list inside of it and the second one has a Datalist. When user changes the...
3
by: John Smith | last post by:
I am having a brain fart today.... How do you set a default button within a User Control? I am using "Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit")" but it does not seem to be working...
0
by: yousuf | last post by:
I have a dataList that pulls from a database table - Im trying to do the normal Edit, Update, Delete, Cancel - on it. when I put the following inside a user control - .ascx file it dosn't work,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.