stop data saved twice when page is refreshed
-
1. Redirect your page on new location when data is successfully saved when user refresh the page it found new page refreshed which is not contains any sort of data saving code. 2. Clear all the state of controls after data saving and write state check condition before data save but I think first approach is better approach if you found any difficulty then I will send you sample code but remember if user go back to page and repeat same activity then you have to give dynamic image by that you always check random image code before saving same as in yahoo, google.
-
you just paste it below your class declaration private bool _refreshState; private bool _isRefresh; public bool IsRefresh { get { return _isRefresh; } } protected override void LoadViewState(object savedState) { object[] allStates = (object[])savedState; base.LoadViewState(allStates[0]); _refreshState = (bool)allStates[1]; _isRefresh = _refreshState == (bool)Session["__ISREFRESH"]; } protected override object SaveViewState() { Session["__ISREFRESH"] = _refreshState; object[] allStates = new object[2]; allStates[0] = base.SaveViewState(); allStates[1] = !_refreshState; return allStates; } and in button click if (!IsRefresh) { //write your code here.. }