Thursday 7 February 2013

Prevent visitors from opening a page outside iframe

Write this java script in each page those resides in iframe

if ( window.self == window.top ) 
{
// not in a frame 
 window.location = "Default.aspx";
}
 else { 
//in a frame 
}

 ..........................

We can use the same concept for Login page in
Situation like.
After session expiry login page rendering into iframe.we can avoid this by write this script into login page

if ( window.self != window.top ) 
{
// In a frame 
 window.location = "Login.aspx";
}
 else { 
//Not in a frame 
}
 

Sunday 3 February 2013

Bind only 25 characters to the Label Text in Gridview control

First use template field rather than bound filed in Gridview, and bind using

 <ItemTemplate>
  <asp:Label ID="lblName" runat="server" 
Text=' <%# Eval("NAME").ToString().Length > 25 ? Eval("NAME").ToString().Substring(0, 23)+"..": Eval("NAME")%>'>
</asp:Label>
 </ItemTemplate>

Total Pageviews