CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 5/24/2004 1:37:08 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 21 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
aspnetgroove
Asp.Net User
determine ClientIDs within a UserControl's code ?5/24/2004 1:37:08 AM

0/0

Stepping through code in my UserControl , I notice that

1. for controls contained within my UserControl , Control.ClientID is built on only the naming hierarchy from the UserControl on down

2. Page.ClientID returns blank

Within a UserControl's code , is it possible to determine a contained control's ClientID as ASP.NET will render it in the page served to the client ?



dkurok
Asp.Net User
Re: determine ClientIDs within a UserControl's code ?5/24/2004 8:01:08 PM

0/0

Just use the property Control.UniqueID, which gives you the ID the control will get at client's side. But be careful - it is only available after you've got added the control to a container-control, which itself has a unique id (and so itself has been added to a container control....)
Hope that helps
Dietmar Kurok
master4eva
Asp.Net User
Re: determine ClientIDs within a UserControl's code ?5/25/2004 1:45:33 PM

0/0

Simple answer to the OQ -- it cannot be done like that. It will disrupt a whole bunch of stuff. For example, it will disrupt the post backs for buttons (the ID will be jepodized and confused with other elements).
-- Justin Lovell
diana_fg
Asp.Net User
Re: determine ClientIDs within a UserControl's code ?8/20/2004 9:41:19 AM

0/0

Hi all,

I have managed with this by defining a server side property 'InstanceName' in the UserControl. I explicitly set its value (the same as the ID) when creating the control instance.

<MYTAGPREFIX:MYCONTROLNAME Runat="server" (...) ID="someID" InstanceName="someID"></MYTAGPREFIX:MYCONTROLNAME>

In the client side I use document.getElementById(<%= InstanceName %> + '_' + myElementName) instead of myElementName.

Another way is to read the prefix from the name of a client control:

function GetNamePrefix(control)
{
(...)
var posEnd = control.name.indexOf(":");
return control.name.substring(0, posEnd);
}
The prefix will be the same for every control in the container. You can store it and use it everywhere: document.getElementById(prefix + '_' + myElementName)

The full thing is a little tricky and seems quite inefficient, but it mostly works. However there are a lot of specific cases where I had to look for another workarounds as this solution was not working. The most difficult situation is when there are several instances of the same User Control in a container document. I'm not sure it is worth the effort.

Best regards,

Diana
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Easily refresh an UpdatePanel, using JavaScript | Encosia One way to do that is to write out a JavaScript array of ClientIDs to the .... Finally, you’ll want to enclose up1_unload’s code in an IsPostBack block of ...
Michael Codes .NET | Michael Johnson's Technology Blog Applications = Code + Markup by Charles Petzold (excellent reference, ... you have a label within a GridView row within a UserControl within a Repeater. ...
ASP.NET WebControl ClientID Bloat Aug 11, 2008 ... Michael Codes .NET. Michael Johnson's Technology Blog ... you have a label within a GridView row within a UserControl within a Repeater. ...
Javascript in UserControl - ASP.NET Forums can u provide the javascript code u r using in the user control so .... to create a JavaScript array of the ListBox ClientIDs and call your ...
INamingContainer and ClientID for nested Composite Controls ... means i have to have server side code to determine clientIds in my ... UserControls would be useful.... ... properties with (i.e. you can't expose a simple ...
CoDe Magazine - Article: What’s Ailing ASP.NET Web Forms? Figuring out exactly when each piece of code in your Page fires as well as when every control or user control fires takes a solid understanding of the full ...
Control Development Modify the control’s code to make it aware that it may be running at .... NET will ensure that the UniqueIDs and ClientIDs of your control’s children ...
ClientID But I got strange ClientIDs return to me. When ... building controls within controls, the clientID will be parentcontrol.clientID + ID. ...
Problem with standart html inputs and UserControls - telerik Forum ... are placed into a page BUT html inputs are in a UserControl so their ClientIDs are not so simple. Problem is that when i use this code ...
Creating a Simple Site Wide User Notification Pattern Feb 27, 2008 ... This small piece of javascript will be registered to the page when the user control is rendered and populated with the ClientIDs of our ...




Search This Site:










per-user odbc?

user control postback problem

composite controls

little (very) help please

c# web service and web site hosting

cookie expiry

page class is 'not set to an instance of an object'

how to use code-behind with custom user control

.net controls 2.0 > 1.1

how to change the page setting of ie

user control menu

exposing data properties of dropdownlist in composite control

get cursor location in textbox

composite controls position

aspnethostingpermission problem

inheritance and adding events

am i misunderstanding something?

webcontrol presentation at design and runtime ?

amazing low rates asp.net, sql 2005 hosting plans here..

child control is not loding properly.

how to write data to htmlinputhidden?

how to get rows and columns collection in a data bound server control, independent of datasource attached.

using table properties in inherited class

issue with validators as child controls

viewstate issue within metabuilders masterpages

using controlpersister.persistcontrol at run time

include asp file in your asp.net application

browsable property in basepage class

clear windows logs in command.

applying a mask to a password textbox control

  Privacy | Contact Us
All Times Are GMT