[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), WebSysDescription(
"
Control_ClientID
"
), Browsable(
false
)]
public virtual string ClientID
{
get
{
this .EnsureID();
string uniqueID = this .UniqueID;
if ((uniqueID != null ) && (uniqueID.IndexOf( this .IdSeparator) >= 0 ))
{
return uniqueID.Replace( this .IdSeparator, ' _ ' ); }
return uniqueID;
}
}
//ClientID就是将UniqueID中的IdSeparator (其值为:”$”)替换为”_”。
public virtual string ClientID
{
get
{
this .EnsureID();
string uniqueID = this .UniqueID;
if ((uniqueID != null ) && (uniqueID.IndexOf( this .IdSeparator) >= 0 ))
{
return uniqueID.Replace( this .IdSeparator, ' _ ' ); }
return uniqueID;
}
}
//ClientID就是将UniqueID中的IdSeparator (其值为:”$”)替换为”_”。
[Browsable(
false
), WebSysDescription(
"
Control_UniqueID
"
), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual string UniqueID
{
get
{
if ( this ._cachedUniqueID == null )
{
Control namingContainer = this .NamingContainer;
if (namingContainer == null )
{
return this ._id;
}
if ( this ._id == null )
{
this .GenerateAutomaticID();
}
if ( this .Page == namingContainer)
{
this ._cachedUniqueID = this ._id;
}
else
{
string uniqueIDPrefix = namingContainer.GetUniqueIDPrefix();
if (uniqueIDPrefix.Length == 0 )
{
return this ._id;
}
this ._cachedUniqueID = uniqueIDPrefix + this ._id;
}
}
return this ._cachedUniqueID;
}
}
public virtual string UniqueID
{
get
{
if ( this ._cachedUniqueID == null )
{
Control namingContainer = this .NamingContainer;
if (namingContainer == null )
{
return this ._id;
}
if ( this ._id == null )
{
this .GenerateAutomaticID();
}
if ( this .Page == namingContainer)
{
this ._cachedUniqueID = this ._id;
}
else
{
string uniqueIDPrefix = namingContainer.GetUniqueIDPrefix();
if (uniqueIDPrefix.Length == 0 )
{
return this ._id;
}
this ._cachedUniqueID = uniqueIDPrefix + this ._id;
}
}
return this ._cachedUniqueID;
}
}
如果控件的ID为空,则对控件自动编号
this.GenerateAutomaticID();
如果当前的控件容器是Page或者为null,则UniqueID就是控件的ID.
否则 取得父控件UniqueID+分隔符($)作为当前控件的UniqueID前缀.
internal
virtual
string
GetUniqueIDPrefix()
{
this .EnsureOccasionalFields();
if ( this ._occasionalFields.UniqueIDPrefix == null )
{
string uniqueID = this .UniqueID;
if ( ! string .IsNullOrEmpty(uniqueID))
{
this ._occasionalFields.UniqueIDPrefix = uniqueID + this .IdSeparator;
}
else
{
this ._occasionalFields.UniqueIDPrefix = string .Empty;
}
}
return this ._occasionalFields.UniqueIDPrefix;
}
{
this .EnsureOccasionalFields();
if ( this ._occasionalFields.UniqueIDPrefix == null )
{
string uniqueID = this .UniqueID;
if ( ! string .IsNullOrEmpty(uniqueID))
{
this ._occasionalFields.UniqueIDPrefix = uniqueID + this .IdSeparator;
}
else
{
this ._occasionalFields.UniqueIDPrefix = string .Empty;
}
}
return this ._occasionalFields.UniqueIDPrefix;
}