Click here to Skip to main content
12,953,175 members (52,123 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » Howto » Downloads


21 bookmarked
Posted 1 Feb 2007

ASP.NET: How to Resolve Client ID

, 1 Feb 2007 CPOL
A method to resolve the client IDs of controls in containers.
/// <summary>
/// FileName: mycontrol.ascx.cs
/// Purpose: controls container
/// Author: 0garcia ( 
/// Update/Fix History:
/// 0g01302007 Initial Implementation
/// </summary>

namespace ResolveClientId
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;

	/// <summary>
	///		Summary description for ValidateControl.
	/// </summary>
	public class myControl : System.Web.UI.UserControl
		protected System.Web.UI.WebControls.TextBox mytext;
		protected System.Web.UI.WebControls.Literal   ctrlPrefix;

		private void Page_Load(object sender, System.EventArgs e)
			string name = this.ClientID;
			string []elm =ctrlPrefix.ClientID.Split('_');		//get an array of values 
			ctrlPrefix.Text = ctrlPrefix.ClientID.Replace(elm[elm.Length - 1],"");    //get the last element and replace from the id     

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
			this.Load += new System.EventHandler(this.Page_Load);


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ozkar garcia
Architect OG-BITechnologies
United States United States

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 1 Feb 2007
Article Copyright 2007 by ozkar garcia
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid