Saturday, 19 October 2013

How to Disable Right Click on your web page?

In your web page just add this code.............

<body oncontextmenu="alert('Right click is disable');return false;"onselectstart="return false" ondragstart="return false" >
Hi hello
Welcome
<br/>
Right Click Disable Example................................
</body>

Thursday, 3 October 2013

How to use DataPager Control in ASP.NET using C#?



DataPager Example in ASP.NET using C#

DataPager in ASP.NET is used for paging. DataPager is divided the big data items into pages.


In this example I use ListView and DataPager. I use SQLDataSource for data binding.

Database:
 Table Name: EmpDetails

Default.aspx(Design View)
 

Default.aspx(Source View):

<asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="#CC3300"
                                        style="text-decoration: underline" Text="Example of DataPager"></asp:Label>

<td>
     <asp:SqlDataSource ID="SqlDataSource1" runat="server"                                         ConnectionString="<%$ ConnectionStrings:DataPagerDBConnectionString %>"
        SelectCommand="SELECT * FROM [EmpDetails]"></asp:SqlDataSource>
 </td>

Create a ListView with ItemTemplate containing the fields that you want to show from Employee table and Create the LayoutTemplate that will represent that how ListView will look

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" ItemPlaceholderID="itemPlaceHolder">
          <LayoutTemplate>
               <table>
                   <tr>
                       <th width="250">  Employee ID  </th>
                       <th width="150">  Employee Name </th>
                       <th width="100">  Department   </th>
                   </tr>
      <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
             </table>

</LayoutTemplate>
  <ItemTemplate>
        <tr>
           <td> <%# Eval("ID") %></td>
           <td> <%# Eval("Name") %></td>
           <td><%# Eval("Dept") %></td>
        </tr>

    </ItemTemplate>
 </asp:ListView>

Put the DataPager inside the ListView LayoutTemplate or anywhere on that page. Here I am putting the DataPager inside the LayoutTemplate.


<td>
   <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1"
         PageSize="2">
              <Fields>
                  <asp:NextPreviousPagerField />
                  <asp:NumericPagerField />
                  <asp:NextPreviousPagerField />
              </Fields>
    </asp:DataPager>
</td>


You will Editfield by clicking on Edit pager Field. You can see the following image.

Step 1:
 

 Step 2:


                OutPut:

1.

 

2.