shake demo

Click to shake the box.

Wednesday, 24 December 2014

ASP TOOLTIP ELIPSIS-

 

Option 1:

To trim text and show ellipsis to the cells of a column in gridview, use a TemplateField with a label and use CSS3's text-overflow option. Then in the 'ToolTip' property of the label field, add code to bind the field with the value from data source as shown below.
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="false">
    <Columns>
     <asp:TemplateField HeaderText ="Product_Review">
           <ItemTemplate>
                 <div style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100px">
                      <asp:Label ID="review" runat="server" Text='<%# Bind("Product_Review") %>' Tooltip='<%#Bind("Product_Review")%>'></asp:Label>
                 </div>
           </ItemTemplate>
           <HeaderStyle Wrap="false" Width="100" HorizontalAlign="Left" />
           <ItemStyle Wrap="false" Width="100"></ItemStyle>
     </asp:TemplateField>
    </Columns>
</asp:GridView>
 
 

Option 2:

Use the same logic to trim text and show ellipsis, use gridview's RowDataBound event to display tooltip. Here we find the label control and use its text value to display tooltip.

<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="false">
   <Columns>
       <asp:TemplateField HeaderText ="Product_Review" HeaderStyle-ForeColor="Orange">
                <ItemTemplate>
                    <div style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100px">
                        <asp:Label ID="review" runat="server" Text='<%# Bind("Product_Review") %>'></asp:Label>
                    </div>
                </ItemTemplate>
                <HeaderStyle Wrap="false" Width="100" HorizontalAlign="Left" />
                <ItemStyle Wrap="false" Width="100"></ItemStyle>
        </asp:TemplateField>
    </Columns>
</asp:GridView> 
Codebehind:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           Label lblReview = (Label)e.Row.FindControl("review");
           string tooltip = lblReview.Text;
           e.Row.Cells[4].Attributes.Add("title", tooltip);
       }
   }

 Sample output is shown below,






 

SQL Server query to delete objects

declare @n char(1)
set @n = char(10)

declare @stmt nvarchar(max)

-- tables
select @stmt = isnull( @stmt + @n, '' ) +
    'drop table [' + schema_name(schema_id) + '].[' + name + ']'
from sys.tables

-- stored procedures
select @stmt = isnull( @stmt + @n, '' ) +
    'drop procedure [' + schema_name(schema_id) + '].[' + name + ']'
from sys.procedures


-- check constraints
select @stmt = isnull( @stmt + @n, '' ) +
'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + ']    drop constraint [' + name + ']'
from sys.check_constraints

-- functions
select @stmt = isnull( @stmt + @n, '' ) +
    'drop function [' + schema_name(schema_id) + '].[' + name + ']'
from sys.objects
where type in ( 'FN', 'IF', 'TF' )

-- views
select @stmt = isnull( @stmt + @n, '' ) +
    'drop view [' + schema_name(schema_id) + '].[' + name + ']'
from sys.views

-- foreign keys
select @stmt = isnull( @stmt + @n, '' ) +
    'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']'
from sys.foreign_keys



-- user defined types
select @stmt = isnull( @stmt + @n, '' ) +
    'drop type [' + schema_name(schema_id) + '].[' + name + ']'
from sys.types
where is_user_defined = 1


exec sp_executesql @stmt


===============================
select how many records in a table

CREATE TABLE  #rowcount (tablename varchar(128), records_in_table int)

EXEC sp_MSforeachtable
 @command1 = 'Insert into #rowcount select ''?'',
              count(*) from ?',
 @whereand = 'and o.name like ''c%''',
 @postcommand = 'SELECT * from #rowcount'

DROP TABLE  #rowcount

LOCK PC using C# code

using System.Runtime.InteropServices;


 public partial class Trends : System.Web.UI.Page
    {
[DllImport("user32.dll")]
        public static extern void LockWorkStation();

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               
            }
        }

public static void LockScreen()
        {
            LockWorkStation();
        }
        protected void btnLockPC_Click(object sender, EventArgs e)
        {

            LockScreen();
       
        }
}