For .net 4.0 if you get the above error you have to add
<httpRuntime requestValidationMode="2.0" />
Inside the <system.web> tags and
ValidateRequest="false" in <Page> directive of .aspx page
Tuesday, August 9, 2011
Thursday, June 23, 2011
Oracle cache dependency in asp.net
private DataSet bindCachedData()
{
string sql = "SELECT * FROM np_pucm_refresh_cal";
constr = "user id=NPUSER;data source=PNPSCAL;password=NPUSER;Min Pool
Size=1;Connection Lifetime=0;Connection Timeout=60;Incr Pool
Size=1;Decr Pool Size=1;";
DataSet ds;
ds = (DataSet)Cache.Get("UserTable");
if (ds ==null)
{
lblMsg.Text = "Data fetched from Table";
using (OracleConnection con = new OracleConnection(constr))
{
con.Open();
using (OracleCommand cmd = new OracleCommand(sql, con))
{
OracleDependency dep = new OracleDependency(cmd);
cmd.Notification.IsNotifiedOnce = false;
dep.OnChange += new OnChangeEventHandler(OnMyNotificaton);
OracleDataAdapter da = new OracleDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
Cache.Insert("UserTable", ds);
}
}
}
else
lblMsg.Text = "Data fetched from Cache";
return ds;
}
public void OnMyNotificaton(object src, OracleNotificationEventArgs arg)
{
DataTable changeDetails = arg.Details;
Cache.Remove("UserTable");
lblMsg.Text = "Data fetched from Table";
}
protected void Timer1_Tick(object sender, EventArgs e)
{
GridView1.DataSource = bindCachedData();
GridView1.DataBind();
}
{
string sql = "SELECT * FROM np_pucm_refresh_cal";
constr = "user id=NPUSER;data source=PNPSCAL;password=NPUSER;Min Pool
Size=1;Connection Lifetime=0;Connection Timeout=60;Incr Pool
Size=1;Decr Pool Size=1;";
DataSet ds;
ds = (DataSet)Cache.Get("UserTable");
if (ds ==null)
{
lblMsg.Text = "Data fetched from Table";
using (OracleConnection con = new OracleConnection(constr))
{
con.Open();
using (OracleCommand cmd = new OracleCommand(sql, con))
{
OracleDependency dep = new OracleDependency(cmd);
cmd.Notification.IsNotifiedOnce = false;
dep.OnChange += new OnChangeEventHandler(OnMyNotificaton);
OracleDataAdapter da = new OracleDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
Cache.Insert("UserTable", ds);
}
}
}
else
lblMsg.Text = "Data fetched from Cache";
return ds;
}
public void OnMyNotificaton(object src, OracleNotificationEventArgs arg)
{
DataTable changeDetails = arg.Details;
Cache.Remove("UserTable");
lblMsg.Text = "Data fetched from Table";
}
protected void Timer1_Tick(object sender, EventArgs e)
{
GridView1.DataSource = bindCachedData();
GridView1.DataBind();
}
Wednesday, June 15, 2011
Import a div's content into excel using javascript
Call the bellow js function "OnClientClick" event of a button
<script language="javascript" type="text/javascript">
function ABC() {
var strCopy = document.getElementById('calendar').innerHTML;
window.clipboardData.setData("Text", strCopy);
var objExcel = new ActiveXObject("Excel.Application");
objExcel.visible = true;
var objWorkbook = objExcel.Workbooks.Add;
var objWorksheet = objWorkbook.Worksheets(1);
objWorksheet.Paste;
return false;
}
</script>
<script language="javascript" type="text/javascript">
function ABC() {
var strCopy = document.getElementById('calendar').innerHTML;
window.clipboardData.setData("Text", strCopy);
var objExcel = new ActiveXObject("Excel.Application");
objExcel.visible = true;
var objWorkbook = objExcel.Workbooks.Add;
var objWorksheet = objWorkbook.Worksheets(1);
objWorksheet.Paste;
return false;
}
</script>
Sunday, April 10, 2011
Create a Win Form with curved corners
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace SampleFormApplication
{
public partial class Login : Form
{
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect,
int nTopRect,
int nRightRect,
int nBottomRect,
int nWidthEllipse,
int nHeightEllipse
);
public Login()
{
InitializeComponent();
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width - 10, Height - 10, 50, 50));
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace SampleFormApplication
{
public partial class Login : Form
{
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect,
int nTopRect,
int nRightRect,
int nBottomRect,
int nWidthEllipse,
int nHeightEllipse
);
public Login()
{
InitializeComponent();
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width - 10, Height - 10, 50, 50));
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Subscribe to:
Posts (Atom)