Feeds:
Posts
Comments

Archive for the ‘Web Development with ASP.NET’ Category

Its very common problem every web developer has to face that is re-submitting data on page refresh (F5).

You will find lots of solution whiling googling but some of them are very lengthy and some are very confusing. I found very easy and effective way of handling this problem.

Using session[] and viewstate[]

On page load take one session variable and store system current date time

if (!IsPostBack)
{
Session[“Refresh”] = Server.UrlDecode(System.DateTime.Now.ToString());
}
On Button click event check whether session and viewstate are same value or not, If same then do your login

if (Session[“Refresh”].ToString() == ViewState[“Refresh”].ToString())
{

[  Do your coding  here ]

Session[“Refresh”] = Server.UrlDecode(System.DateTime.Now.ToString());
}
else
{
response.write(“You have refreshed the page”)
}

Write one Page pre render event to assing session value in viewstate  like this
protected void Page_PreRender(object sender, EventArgs e)
{
ViewState[“Refresh”] = Session[“Refresh”];
}

Thats all….happy coding

 

 

Read Full Post »

F:\image.jpg=exefile

Read Full Post »

For disabling right click on image use this attribute in body tag

<body oncontextmenu=”return false”>

Read Full Post »

Use this markup to disable image toolbar for all the images in the page

<meta http-equiv=”imagetoolbar” content=”no” />

For individual image use this markup

<img src=”image.jpg” gallerying=”no” />


Read Full Post »

Use this attributes to disable copying from your page

<body ondragstart=”return false” onselectstart=”return false”>

Read Full Post »