What is Unobtrusive Validation?

In a normal validation scenario, when we use a validator to validate any control and use Client side validation, some JavaScript is generated and rendered as HTML. Also some supportive JavaScript files also get loaded by the browser for the validation.

Now with feature Unobtrusive Validation, inline JavaScript is not generated and rendered to handle the Client Side validation. Instead of this, it uses HTML5 data-* attributes for all these validation.

S0 now let’s see a normal scenario. I have taken textbox and applied two ASP.NET validators on it. One is RequiredFieldValidator and RangeValidator that allows to enter the value between 100 and 1000. Let’s see the aspx code:


Đọc dữ liệu từ Excel

Mã nguồn dưới đây hướng dẫn cách đọc dữ liệu từ Excel vào cơ sở dữ liệu

var fullFileName =”PathOfExcelFile”;
var connectionString = string.Format(“Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 8.0;data source={0};”, fullFileName);
var adapter = new OleDbDataAdapter(“select * from [Ten_Sheet$]”, connectionString);
var ds = new DataSet();
string tableName = “tableName”;
adapter.Fill(ds, tableName);
DataTable data = ds.Tables[tableName];
dataGridView1.DataSource = data;