Getting null value

Vote:
 
whenever checking CurrentPage.Property["tableofcontents"]  value returning null even though property names tableofcontents has value or data.what can be problem?
#31307
Jul 20, 2009 15:19
Vote:
 
Remember that the EPiServer property name is case sensitiv. Make sure it is spelled correctly by copying the name from the admin interface. Do you get any data when adding <EPiServer:Property runat="server" PropertyName="tableofcontents" /> to your page?
#31309
Jul 20, 2009 15:53
Vote:
 

CurrentPage.Property["tableofcontents"].ToString()  is giving value but whenever we try to check null value using this line of code CurrentPage.Property["tableofcontents"]!=null then it always gives null value.why?

#31310
Jul 20, 2009 16:18
Vote:
 

 

 Following is code on aspx page:

<div id="spotlight_publications1" >
<ul>
<episerver:PageList PageLinkProperty="PageLink"  paging=true    PagesPerPagingItem=10   runat="server" ID="publications" >
 <ItemTemplate>
 
  
 <%  if (CurrentPage.PageLink.ID==4946)
 {%>
 <table border="0" width="100%" >
  <tr>
  
   <%
    try { if(CurrentPage.Property["SpotlightImage"]!=null )
   {%>
   <td valign=top  > <img src='<%# Container.CurrentPage.Property["SpotlightImage"]%>' alt="Image" width=90 height=75 align=left/></td>
    
   <%}
   else
   {%>
    <td valign=top > <img src=../../images/hrsummit.jpg alt="Image" width=90 height=75 align=left/></td>
   
   <%}}
   %>
   
   <% catch(Exception ex)
   {}
   %>
   
   <td  >
    <table >
     <tr>
      <td colspan="2">
      <div id="red_title">
       
       <episerver:property   PropertyName="PageLink"    runat="server"  ID="Property2" name="Property1"/>
      </div>
      </td>
     </tr>
     <tr>
     
      <td colspan="2">
      <div id="gray_title">
       Key Highlights
      <!--<img src='../../images/Key-Highlights.jpg' alt="Key Highlights" width=150>-->
      </div> 
      </td>
     </tr>
     <tr>
      <td colspan="2">
       <%# Container.CurrentPage.Property["Description"].ToString() %>
      </td>
     </tr>
     <tr>
      
      <td valign=top>
       <table>
        <tr>
         <td>
         <div id="gray_title">
         Table Of Content
         <!--<img src='../../images/Tabel-of-Content.jpg' alt="Tabel of Content" width=150></td>-->
         </div>
         </td>
        </tr>
        <tr>
         <td><%# Container.CurrentPage.Property["TableofContents"].ToString() %></td>
        </tr>
       </table>
      </td>
           
      <td valign=top>
       <table>        
        <tr>
         <td>
          <%
          i++; 
          if(i==10)
          {%>
           <NS:Payment PageLink='<%# Container.CurrentPage %>' visibleline="true" ru1nat=server ID="Price1">
           </NS:Payment>
          
           <NS:Price1 PageLink='<%# Container.CurrentPage %>' visibleline="true" runat=server ID="Price13">
           </NS:Price1>
          <% 
          }
          else
          {%>
           <NS:Payment PageLink='<%# Container.CurrentPage %>' visibleline="false" r1unat=server ID="Price2">
           </NS:Payment>
           
           <NS:Price1 PageLink='<%# Container.CurrentPage %>' visibleline="false" runat=server ID="Price14">
           </NS:Price1>
          <%
          }%>
         </td>
        </tr>
       </table>      
      </td>     
     </tr>
     </table>
     </td>   
  </tr>
  <tr><td colspan="2"><hr/></td></tr>
 </table>
</ItemTemplate>
</ul>
</div> 

#31311
Jul 20, 2009 16:27
Vote:
 

If you're using it inside the PageList you have to add Container.CurrentPage.Property["tableofcontents"] != null

#31319
Jul 20, 2009 18:17
Vote:
 

Btw. - don't think property names are case sensitive.

CurrentPage.Property["propname"] will give you the PropertyData object, not the value.

CurrentPage["propname"] will give you the value, or null if the value is null or the property does not exist on the page.

 

#31322
Jul 20, 2009 21:19
Vote:
 
thanks guys.we solved this problem.
#31330
Jul 21, 2009 9:36
Vote:
 

You're right Steve, just did a test and both Test and test work for ProperyName.

Ajay Singh: how did you solve it?

#31333
Jul 21, 2009 11:58