473,770 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unique ID changing between postbacks!

I have an asp.net control which on the first Load of the page has a
unique ID something like:

_ctl0__ctl1_Gro upName__ctl1_Co ntrolName

and after the first postback it changes to:

_ctl0__ctl1_Gro upName__ctl0_Co ntrolName

which is very bad, because I'm using javascript which relies on the
unique id not changing between postbacks. If anyone has any ideas on
why that's changing, I'd really appreciate it. I know how asp.net sets
the unique id up to _ctl0__ctl1_Gro upName_ but i don't know where it's
deciding the ctl0 or ctl1 part of it.
Thanks!

Nov 19 '05 #1
3 3338
if you do not give a control an id, its assigned based on its index in its
parents collection. in your case the control is nested four deep, with only
one (GroupName) assigned a name. the name changes because between postbacks
you are changing the number of controls. you should not hardcode this names
in javascript, but rather register client script with the controls uniqueid.

-- bruce (sqlwork.com)
"John" <br******@hotma il.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
| I have an asp.net control which on the first Load of the page has a
| unique ID something like:
|
| _ctl0__ctl1_Gro upName__ctl1_Co ntrolName
|
| and after the first postback it changes to:
|
| _ctl0__ctl1_Gro upName__ctl0_Co ntrolName
|
| which is very bad, because I'm using javascript which relies on the
| unique id not changing between postbacks. If anyone has any ideas on
| why that's changing, I'd really appreciate it. I know how asp.net sets
| the unique id up to _ctl0__ctl1_Gro upName_ but i don't know where it's
| deciding the ctl0 or ctl1 part of it.
|
|
| Thanks!
|
Nov 19 '05 #2
Thanks Bruce,

I do give the control an id, which is where it puts ControlName in:
_ctl0__ctl1_Gro upName__ctl0_Co ntrolName

And I am registering it on the client side. Which is the problem.
Here's the situation:

I have, lets say, an asp.net button, and I don't want to wait for the
postback to handle it. So I register a client side script which says
when this button is pushed, store a value in a list, along with it's
uniqueid(actual ly clientid, because html doesn't like colons). Then
when i do the postback, right away check to see if that list contains
anything, and if it contains this buttons unique id, look at the value,
and gather the information.

This works on every other page I use, but for some reason somethings
changing on this one that causes it's fully qualified ID to change.

Nov 19 '05 #3
Wow, thanks Bruce. It was a webuser control that I had as a sub
control, which didn't have it's ID explicitly set.. now everything is
back to normal... thank you very much!!

Nov 19 '05 #4

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

Similar topics

26
45447
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.) How can I achieve this? I suppose I would get the most-hated "table/view is changing, trigger/function may not see it" error if I tried to write a trigger that checks the uniqueness of non-null values upon insert/update.
4
15653
by: Louis Frolio | last post by:
Greetings All, I have read many upon many articles here regarding GUID data types and uniqueness. There have been many opinions regarding the effectiveness of GUID's and when they should/should not be used. However, every article strongly implies, if it does not state it outright, that GUID's are always unique. My question is this, what happens if you have a database that uses GUID's and the NIC is changed out on the box? From what I...
6
2908
by: Velislav | last post by:
Hi, I have a client script block, which is registered in my Page_Load. However a button may result in the need to change the script which I've registered. Obviously the OnClick event occurs after Page_Load, so calling RegisterClientScriptBlock with the same key does nothing.
0
982
by: gregfocker | last post by:
I installed the new RTM version of ASP.NET 2.0 AJAX Extensions 1.0 released on Tuesday (1/23). I made the required changes to the web.config file to go from the RC version to the RTM version. Now, what once did partial, async. postbacks correctly in my app are now regular postbacks - page refresh and everything. I even started from scratch with a simple sample (script mgr., update panel, grid view), and that also does full postbacks. ...
28
4108
by: Matuag | last post by:
How can we create a unique and non-editable ID from client's first and last name? eg.: SmitJ1 for John Smith Matuag
1
2361
by: Khafancoder | last post by:
Hi guys, i'm trying to change all of page control's (root controls and inner controls) forecolor in PreRender event. it works fine but when a postback occures by detailsview command buttons, it fails... (i trace the code, it even executes in postbacks but control's forecolor don't change)
4
2525
by: Nathan Sokalski | last post by:
I have 2 private variables in my class that I need to remember the values of between postbacks (or actually callbacks, since I am using AJAX). I want to avoid using session variables, if possible. Is there any other way to have VB.NET maintain the values of these variables between postbacks & callbacks? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
6
4355
by: =?Utf-8?B?QWxwaGFwYWdl?= | last post by:
Hello, I want to generate a unique ID for each page of my Asp.Net application. My first step is to generate a new Guid when the page is loaded for the first time and registers, stores this new Guid in a Dictionary which is saved in the ApplicationState, then I add a hidden field to the page __PageID, so I can get this unique ID on other Postbacks. No problem. The problem is about hackers. They can modify my hidden field to another...
0
1383
by: Gabriel Genellina | last post by:
En Fri, 18 Apr 2008 12:23:08 -0300, Shawn Milochik <Shawn@Milochik.comescribió: A dictionary with keys is perfectly reasonable. But a *list* of values has to be searched linearly for every value: a O(n) process. As your friend suggested, searching a dictionary requires O(1) time. A set is even better in this case, because you don't have any use for the values in the inner dictionary (sets and dictionaries are very similar in the...
0
9617
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...
1
10037
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
9904
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
7456
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
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.