Pages

Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Saturday, May 17, 2014

Embed PDF in HTML Page


To Embed PDF files in HTML Page You can use below snippet of code, It works in most browser versions (Chrome, Firefox, IE,... ).

if it is not supported, it shows the message "The PDF cannot be displayed."

<div id="pdf">
<object width="900" height="1000" type="application/pdf" data="/filepath/filename.pdf?#zoom=85&scrollbar=0&toolbar=0&navpanes=0" id="pdf_content">
<p>The PDF cannot be displayed. <a href="/filepath/filename.pdf" target="_top">download</a>.</p>
</object>
</div>

Above snippet of code sets the zoom to 85%, removes scrollbars, toolbars and nav panes.

Hope it helps J

Friday, February 28, 2014

HOW TO: Remove Duplicate Data using LINQ

Few days back i needed to remove duplicate ITEM_ID field values of  queried data using LINQ..

So basicly all I had to do is to Group the results by ITEM_ID and then select the first returned data in each group:

var queryResult = dataVar.Contents
.OrderByDescending(o => o.ITEM_ID)
.Where(x => x.userNAME.Contains(searchKeyTxtBx.Text))     \\ filter the data
.GroupBy(p => p.ITEM_ID)    \\ Group By Item ID
.Select(g => g.First())     \\ select the first in each group
.ToList();     \\ final data have NO duplicate ITEM_ID values

Monday, October 31, 2011

How to find a control in a DataList?


How to find a control in a DataList?

Because DataList is databound control which repeats its item template as many times as there are rows in the data source. Therefore contents of
So, to locate a specific Label control, you’d first need to locate a specific dataList item, and run FindControl to it (for example DataList1.Items(0).FindControl(“label2″) ), and considering the databound nature, you’d probably want to loop through all items in the DataList’s Items collection to get to the every Label control.

VB
For Each dli as DataListItem in DataList1.Items
Dim currLbl As Label=DirectCast(dli.FindControl(“label2″),Label)
    '…
Next


C#
foreach(DataListItem dli in DataList1.Items)
{
Label currLbl = (Label) dli.FindControl(“label2″);
//…

}