Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3936192
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:55:04+00:00 2026-05-19T23:55:04+00:00

I would like to change document icon in document library at runtime. Icon should

  • 0

I would like to change document icon in document library at runtime. Icon should be changed based on some condition I have in code. There is no difference what extension of file is (txt, doc, pdf, etc..). Currently I use HTTP module to parse server response and change icon in runtime. However this solution is not reliable as page HTML markup may be changed, different views has different behavior and there are issues with registration HTTP module in SharePoint 2010.
Is there any API or any other reliable way to change document’s icon at runtime?

I would appreciate any help.
Thanks beforehand,
-Petro

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:55:05+00:00Added an answer on May 19, 2026 at 11:55 pm

    Here is the schema of Sharepoint 2010 standard DocIcon Field (its quite huge):

      <Field ID="{081c6e4c-5c14-4f20-b23e-1a71ceb6a67c}" Type="Computed" ReadOnly="TRUE" Name="DocIcon" DisplayName="Тип" TextOnly="TRUE" ClassInfo="Icon" AuthoringInfo="(значок связи с документом)" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="DocIcon" FromBaseType="TRUE">
      <FieldRefs>
        <FieldRef Name="File_x0020_Type" />
        <FieldRef Name="FSObjType" />
        <FieldRef Name="FileRef" />
        <FieldRef Name="FileLeafRef" />
        <FieldRef Name="HTML_x0020_File_x0020_Type" />
        <FieldRef Name="PermMask" />
        <FieldRef Name="CheckoutUser" ShowField="Title" />
        <FieldRef Name="IsCheckedoutToLocal" />
        <FieldRef Name="ServerUrl" />
        <FieldRef Name="IconOverlay" />
      </FieldRefs>
      <DisplayPattern>
        <SetVar Name="DocIconImg">
          <SetVar Name="DocIconAltText">
            <IfEqual>
              <Expr1>
                <LookupColumn Name="FSObjType" />
              </Expr1>
              <Expr2>1</Expr2>
              <Then>
                <IfSubString>
                  <Expr1>0x0120D5</Expr1>
                  <Expr2>
                    <Column Name="ContentTypeId" />
                  </Expr2>
                  <Then>
                    <HTML>Коллекция документов: </HTML>
                    <LookupColumn Name="FileLeafRef" HTMLEncode="TRUE" />
                  </Then>
                  <Else>
                    <HTML>Папка: </HTML>
                    <LookupColumn Name="FileLeafRef" HTMLEncode="TRUE" />
                  </Else>
                </IfSubString>
              </Then>
              <Else>
                <LookupColumn Name="FileLeafRef" HTMLEncode="TRUE" />
              </Else>
            </IfEqual>
          </SetVar>
          <SetVar Name="DocIconFileName">
            <IfEqual>
              <Expr1>
                <Column Name="IconOverlay" />
              </Expr1>
              <Expr2 />
              <Then>
                <IfEqual>
                  <Expr1>
                    <LookupColumn Name="FSObjType" />
                  </Expr1>
                  <Expr2>1</Expr2>
                  <Then>
                    <IfEqual>
                      <Expr1>
                        <Column Name="HTML_x0020_File_x0020_Type" />
                        <HTML>|</HTML>
                        <Column Name="File_x0020_Type" />
                      </Expr1>
                      <Expr2>
                        <HTML>|</HTML>
                      </Expr2>
                      <Then>
                        <HTML>folder.gif</HTML>
                      </Then>
                      <Else>
                        <SetVar Name="FolderIconFromMap">
                          <MapToIcon>
                            <Column Name="HTML_x0020_File_x0020_Type" />
                            <HTML>|</HTML>
                            <Column Name="File_x0020_Type" />
                          </MapToIcon>
                        </SetVar>
                        <IfEqual>
                          <Expr1>
                            <GetVar Name="FolderIconFromMap" />
                          </Expr1>
                          <Expr2>
                            <MapToIcon />
                          </Expr2>
                          <Then>
                            <HTML>folder.gif</HTML>
                          </Then>
                          <Else>
                            <GetVar Name="FolderIconFromMap" />
                          </Else>
                        </IfEqual>
                      </Else>
                    </IfEqual>
                  </Then>
                  <Else>
                    <MapToIcon>
                      <Column Name="HTML_x0020_File_x0020_Type" />
                      <HTML>|</HTML>
                      <Column Name="File_x0020_Type" />
                    </MapToIcon>
                  </Else>
                </IfEqual>
              </Then>
              <Else>
                <MapToIcon>
                  <Column Name="IconOverlay" />
                </MapToIcon>
              </Else>
            </IfEqual>
          </SetVar>
          <HTML><![CDATA[<img border="0" alt="]]></HTML>
          <GetVar Name="DocIconAltText" />
          <HTML><![CDATA[" title="]]></HTML>
          <GetVar Name="DocIconAltText" />
          <HTML><![CDATA[" src="/_layouts/images/]]></HTML>
          <GetVar Name="DocIconFileName" />
          <HTML><![CDATA[" />]]></HTML>
        </SetVar>
        <SetVar Name="DocIconOverlayImg">
          <IfEqual>
            <Expr1>
              <Column Name="IconOverlay" />
            </Expr1>
            <Expr2 />
            <Then>
              <IfEqual>
                <Expr1>
                  <Column Name="CheckoutUser" />
                </Expr1>
                <Expr2 />
                <Else>
                  <SetVar Name="DocIconOverlayAltText">
                    <LookupColumn Name="FileLeafRef" HTMLEncode="TRUE" />
                    <HTML><![CDATA[&#10;Кем извлечено: ]]></HTML>
                    <LookupColumn Name="CheckoutUser" ShowField="Title" HTMLEncode="TRUE" />
                  </SetVar>
                  <HTML><![CDATA[<img class="ms-vb-icon-overlay" alt="]]></HTML>
                  <GetVar Name="DocIconOverlayAltText" />
                  <HTML><![CDATA[" title="]]></HTML>
                  <GetVar Name="DocIconOverlayAltText" />
                  <HTML><![CDATA[" src="/_layouts/images/checkoutoverlay.gif" />]]></HTML>
                </Else>
              </IfEqual>
            </Then>
            <Else>
              <HTML><![CDATA[<img class="ms-vb-icon-overlay" alt="*" src="/_layouts/images/]]></HTML>
              <MapToOverlay>
                <Column Name="IconOverlay" />
              </MapToOverlay>
              <HTML><![CDATA[" />]]></HTML>
            </Else>
          </IfEqual>
        </SetVar>
        <IfEqual>
          <Expr1>
            <LookupColumn Name="FSObjType" />
          </Expr1>
          <Expr2>1</Expr2>
          <Then>
            <FieldSwitch>
              <Expr>
                <GetVar Name="RecursiveView" />
              </Expr>
              <Case Value="1">
                <GetVar Name="DocIconImg" />
                <GetVar Name="DocIconOverlayImg" />
              </Case>
              <Default>
                <SetVar Name="UnencodedFilterLink">
                  <SetVar Name="RootFolder">
                    <HTML>/</HTML>
                    <LookupColumn Name="FileRef" />
                  </SetVar>
                  <SetVar Name="SkipHost">1</SetVar>
                  <SetVar Name="FolderCTID">
                    <FieldSwitch>
                      <Expr>
                        <ListProperty Select="EnableContentTypes" />
                      </Expr>
                      <Case Value="1">
                        <Column Name="ContentTypeId" />
                      </Case>
                    </FieldSwitch>
                  </SetVar>
                  <FilterLink Default="" Paged="FALSE" />
                </SetVar>
                <FieldSwitch>
                  <Expr>
                    <GetVar Name="FileDialog" />
                  </Expr>
                  <Case Value="1">
                    <GetVar Name="DocIconImg" />
                    <GetVar Name="DocIconOverlayImg" />
                  </Case>
                  <Default>
                    <HTML><![CDATA[<a href="]]></HTML>
                    <GetVar Name="UnencodedFilterLink" HTMLEncode="TRUE" />
                    <HTML><![CDATA[" onmousedown="javascript:VerifyFolderHref(this,event, ']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <GetVar Name="UnencodedFilterLink" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ServerProperty Select="HtmlTrProgId">
                        <Column Name="File_x0020_Type" />
                      </ServerProperty>
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ListProperty Select="DefaultItemOpen" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <MapToControl>
                        <Column Name="HTML_x0020_File_x0020_Type" />
                        <HTML>|</HTML>
                        <Column Name="File_x0020_Type" />
                      </MapToControl>
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <Column Name="HTML_x0020_File_x0020_Type" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ServerProperty Select="GetServerFileRedirect">
                        <Field Name="ServerUrl" />
                        <HTML>|</HTML>
                        <Column Name="HTML_x0020_File_x0020_Type" />
                      </ServerProperty>
                    </ScriptQuote>
                    <HTML><![CDATA[')"]]></HTML>
                    <HTML><![CDATA[" onclick="return HandleFolder(this,event, ']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <GetVar Name="UnencodedFilterLink" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ServerProperty Select="HtmlTransform" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ServerProperty Select="HtmlTrAcceptType">
                        <Column Name="File_x0020_Type" />
                      </ServerProperty>
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ServerProperty Select="HtmlTrHandleUrl">
                        <Column Name="File_x0020_Type" />
                      </ServerProperty>
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ServerProperty Select="HtmlTrProgId">
                        <Column Name="File_x0020_Type" />
                      </ServerProperty>
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ListProperty Select="DefaultItemOpen" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <MapToControl>
                        <Column Name="HTML_x0020_File_x0020_Type" />
                        <HTML>|</HTML>
                        <Column Name="File_x0020_Type" />
                      </MapToControl>
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <Column Name="HTML_x0020_File_x0020_Type" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ServerProperty Select="GetServerFileRedirect">
                        <Field Name="ServerUrl" />
                        <HTML>|</HTML>
                        <Column Name="HTML_x0020_File_x0020_Type" />
                      </ServerProperty>
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <Column Name="CheckoutUser" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <UserID AllowAnonymous="TRUE" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <ListProperty Select="ForceCheckout" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <Field Name="IsCheckedoutToLocal" />
                    </ScriptQuote>
                    <HTML><![CDATA[',']]></HTML>
                    <ScriptQuote NotAddingQuote="TRUE">
                      <Field Name="PermMask" />
                    </ScriptQuote>
                    <HTML><![CDATA[');">]]></HTML>
                    <GetVar Name="DocIconImg" />
                    <GetVar Name="DocIconOverlayImg" />
                    <HTML><![CDATA[</a>]]></HTML>
                  </Default>
                </FieldSwitch>
              </Default>
            </FieldSwitch>
          </Then>
          <Else>
            <HTML><![CDATA[<a href="]]></HTML>
            <Field Name="ServerUrl" URLEncodeAsURL="TRUE" />
            <HTML><![CDATA[" onclick="return DispEx(this,event,']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <ServerProperty Select="HtmlTransform" />
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <ServerProperty Select="HtmlTrAcceptType">
                <Column Name="File_x0020_Type" />
              </ServerProperty>
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <ServerProperty Select="HtmlTrHandleUrl">
                <Column Name="File_x0020_Type" />
              </ServerProperty>
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <ServerProperty Select="HtmlTrProgId">
                <Column Name="File_x0020_Type" />
              </ServerProperty>
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <ListProperty Select="DefaultItemOpen" />
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <MapToControl>
                <Column Name="HTML_x0020_File_x0020_Type" />
                <HTML>|</HTML>
                <Column Name="File_x0020_Type" />
              </MapToControl>
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <Column Name="HTML_x0020_File_x0020_Type" />
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <ServerProperty Select="GetServerFileRedirect">
                <Field Name="ServerUrl" />
                <HTML>|</HTML>
                <Column Name="HTML_x0020_File_x0020_Type" />
              </ServerProperty>
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <Column Name="CheckoutUser" />
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <UserID AllowAnonymous="TRUE" />
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <ListProperty Select="ForceCheckout" />
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <Field Name="IsCheckedoutToLocal" />
            </ScriptQuote>
            <HTML><![CDATA[',']]></HTML>
            <ScriptQuote NotAddingQuote="TRUE">
              <Field Name="PermMask" />
            </ScriptQuote>
            <HTML><![CDATA[')">]]></HTML>
            <GetVar Name="DocIconImg" />
            <GetVar Name="DocIconOverlayImg" />
            <HTML><![CDATA[</a>]]></HTML>
          </Else>
        </IfEqual>
      </DisplayPattern>
    </Field>
    

    You can get DocIcon field of a library you want to modify icons for (through code) and modify its schema. As you can see there are a lot of XSLT in section, but it’s quite simple and new patterns can be added without big problems (and old ones can be removed). Another way is to create your own custom field type and use it instead of standard one to display an icon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to change a line of my javascript code based on whether
I would like to change the style of a text field based on the
I would like to change the database files location of MySQL administrator to another
I would like to change the Row Source values in an Access table through
I would like to change the default behavior of Joomla's password reminding mechanism. I
I would like to change the contents of the list of a JComboBox (like
I would like to change the name of the ruby process that gets displayed
I would like to change the behaviour of the insert button on the standard
I am building a custom win32 control/widget and would like to change the cursor
I am using a third party application and would like to change one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.