Yes this is possible.
when you acsess it via an document's object (divObj.AccessControlID) therefore it is expected that your custom control is rendered like this:
<span AccessControlID="Something" id="SomeID"></span>
I have used span tag in above line for explaining purpose only here. You can assume your div tag also. Not a problem. :)
If that you want to do that, you have to override the following method in your custom control class( Here is sample code block that I tried )
[DefaultProperty("Text")]
[ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
public class WebCustomControl1 : WebControl
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState["Text"] = value;
}
}
protected override void RenderContents(HtmlTextWriter output)
{
output.Write(Text);
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute("AccessControlID", "This is custom attribute value");
base.AddAttributesToRender(writer);
}
}
The above control when used in aspx page and renders like this
<span AccessControlID="This is custom attribute value" id="WebCustomControl1_1"></span>
hence you can access that attribute in javascript or do like this
<script language="javascript" type="text/javascript">
function Search()
{
alert(document.getElementById("WebCustomControl1_1").AccessControlID);
}
</script>
Hope it helps you. Please let me know whether this is what you were looking for.