Is there any way to prevent changing basic element identifiers?

I am looking at adding master pages to an existing site, but have found that as soon as I do this, item identifiers are added with code (for example, ctl00_MainPageContent_).

Unfortunately, this violates existing scripts on the page that use the original, unmodified element identifier.

I understand that I can replace it with <%= Element.ClientID %>, but it would be great if I could completely disable this behavior.

So, can I keep the original identifiers?

+6
source share
3 answers

: MasterPage

Render :

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
    Dim Html As New StringWriter()
    Dim Render As New HtmlTextWriter(Html)
    MyBase.Render(Render)
    writer.Write(Html.ToString().Replace("name=""ctl00$ContentBody$", _ 
                  "name=""").Replace("id=""ctl00_ContentBody_", "id="""))
End Sub
+5

ClientID UniqueID . , .

public override string UniqueID
{
    get
    {
        return this.ID;
    }
}

public override string ClientID
{   
    get
    {
        return this.ID;
    }
}
+4

, - ClientIDMode="Static".

0

All Articles