Tuesday 17 May 2016

How to get prompt message while clicking the F12 key operation in Web site running in the browser?


In this article I will explain How to get prompt message while clicking the F12 key operation in Web site running in the browser? Using jQuery

As a Developer you can see the code in development time it’s OK for you, but when others are trying to see your application code and do some operations definitely we don't want to disclose this. So what is the solution? We can easily prevent this using some simple JavaScript and jQuery scripts.

Clients (or) Users will click the F12 Key they got prompt message like “He / She can’t the code”

Below is JQuery code for F12 Key prompt message code:

<script>
var checkStatus;

var element = new Image();
element.__defineGetter__('id', function () {
checkStatus = 'on';
});

setInterval(function () {
checkStatus = 'off';
console.log(element);
console.clear();
document.querySelector('#status').innerHTML = checkStatus;
}, 1000)
</script>

How to disable the F12 key with mouse right click operations in Web site running in the browser?


In this article I will explain How to disable the F12 key with mouse right click operations in Web site running in the browser? Using Jquery

As a Developer you can see the code in development time it’s OK for you, but when others are trying to see your application code and do some operations definitely we don't want to disclose this. So what is the solution? We can easily prevent this using some simple JavaScript and jQuery scripts.

Clients (or) Users will not be accessing the F12 key with mouse right click options.

Below is JQuery code for disable F12 Key and Mouse Right click Options

<script>
$(document).keydown(function (event) {
if (event.keyCode == 123) {
return false;
}
else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
return false;
}
});

$(document).on("contextmenu", function (e) {
e.preventDefault();
});
</script>

How to convert phone number format using JavaScript like international Format.

In this Article I will explain How to convert phone number format using JavaScript like international Format. For example USA format.  Convert phone number to international format (USA) in JavaScript / jQuery convert number to phone number format with example or JavaScript phone number validation example.

To convert number to phone number / international format in JavaScript we need to write the code like as shown below.

<script type="text/javascript">
function convertphoneNo() {
var phnumber = document.getElementById('txtPhoneNumbernumber').value;
var numbers = phnumber.replace(/\D/g, ''),
char = { 0: '(', 3: ') ', 6: ' - ' };
phnumber = '';
for (var i = 0; i < numbers.length; i++) {
phnumber += (char[i] || '') + numbers[i];
}
document.getElementById('lblResult').innerHTML = phnumber;
}
</script>

How to hide div elements on scroll position using jQuery?

In this article I will explain How to hide div elements on scroll position using jQuery? Or show hide div on scroll position in jQuery or show / hide element on scroll jQuery. In jQuery by using window. Scroll property we can show or hide div element based on position.

Below is the jQuery Script code:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function () {
$(window).scroll(function () {
var scroll = $(window).scrollTop();
if (scroll >= 30) {
$('#divShow').hide()
$('#divHide').show()

}
else {
$('#divShow').show();
$('#divHide').hide()

}
});
})
</script>

Friday 17 April 2015

How to get / fetch data from GridView and store in DataTable Dynamically in ASP.NET using C#.NET?

How to get / fetch data from GridView and store in DataTable Dynamically in ASP.NET using C#.NET?

In this article I will explain how to fetch / get data from a GridView and how to store it into a DataTable dynamically using C#.NET in ASP.NET

Fallow the below steps:

First, we have to create GridView with required Columns and set its AutoGenerateColumns property to False. If you required footer then show footer is true otherwise false and same as paging also.

Design the GridViewas per your reqirements. Use Templates like Item Template, Edit Item Template, and Footer Templates to Create GridView.

How to fetch data from GridView and store in DataTable?

How to fetch data from GridView and store in DataTable in ASP.NET?

In this article I will explain how to fetch data from a GridView and how to store it into a DataTable in ASP.NET

Fallow the below steps:

First, we have to create GridView and set its AutoGenerateColumns property to False.

Design the GridViewas per your reqirements. Use Templates like Item Template, Edit Item 
Template, and Footer Templates to Create GridView.


How to bind DataTable data to Gridview using C#.NET with ASP.NET Dynamically.

How to bind DataTable data to Gridview using C#.NET with ASP.NET Dynamically.

In this article I will explain how to create DataTable and how to bind DataTable data to Gridview Using C#.NET.

To bind DataTable data to gridview we need to write the code like as shown below like ….

<div><asp:GridView ID=" GridView1" runat="server"></asp:GridView></div>

Add below namespaces in code behind…

using System.Data;

 protected void Page_Load(object sender, EventArgs e)
{
BindDataTabelToGridviewData();
}

/// <summary>
/// Dynamically create DataTable & bind data to gridview
/// </summary>

protected void BindGridviewData()
{
        DataTable dtDynamic = new DataTable();

       DataColumn dc = new DataColumn();

        dc = new DataColumn();
        dc.ColumnName = "MatTransSlNo";
        dc.DataType = Type.GetType("System.String");
        dtDynamic.Columns.Add(dc);

        dc = new DataColumn();
        dc.ColumnName = "Amount";
        dc.DataType = Type.GetType("System.Decimal");
        dtDynamic.Columns.Add(dc);

        dc = new DataColumn();
        dc.ColumnName = "DeleteFlag";
        dc.DataType = Type.GetType("System.Int32");
        dtDynamic.Columns.Add(dc);

dtDynamic.Rows.Add(“1”, 101.10,1);
dtDynamic.Rows.Add(“2”, 102.10,0);
dtDynamic.Rows.Add(“3”, 103.10,1);
dtDynamic.Rows.Add(“4”, 104.50,1);

GridView1.DataSource = dtDynamic;
GridView1.DataBind();
}