I developed a web application in asp.net.I have a module for saving values to database after clicking the button event.Thats working successfully.After that when i clicked the browser's refresh button the values reinserted to the table each time.How can i avoid this .Which is the code for this solution?
Here is a nice article on this
Preventing Duplicate Record Insertion on Page Refresh
Related
I want to display a online user indication in image item template of gridview inside a update panel which triggers by a timer in a certain time period. The image item template is getting image from a generic handler (.ashx) using a sql server database. the gridview is getting data from another sql server table which is inside an update panel as mentioned earlier. the problem is- when i login the main page from different browser (IE, Firefox,Chrome) in same pc the first browser which i login first, it is not displaying the latest user online indication. What should i do??? Plz help me.
I am using views concept in my asp.net form control.my first view consist of a form to capture user details.when user press continue it will move to the second view.
The problem is ,When user press the back button of the browser from the second view it doesn't move the the previous view instead move to the previous page in the browser history.
I wanted to move to the first view with the existing data in the form,when user press the back button of the browser.
You should perform a full page postback I guess, so that at client end your previous view will be saved in browser's history.
http://binaryjack.com/userControl.aspx
Each record is displayed using a user control. I have the delete button embedded in the user control.
Recreate Problem: click the first DELETE button, the last row gets deleted; after this I have to click the delete button (any of them) twice to make it work.
Is it bad practice to use a User Control (combined with a placeholder) to display a bunch of records? I query to get all records and then use a Foreach loop to populate each User Control and insert each UC into the placeholder.
Why does the Delete button not respond correctly?
Without seeing your code it is tough to say. However, it appears to be a refresh issue. If you hit delete then hit refresh, the record is gone. Check how you are refreshing the data and you'll find the issue.
I have page that uses a multiview. Each view contains a separate user control. One of these user controls has a list view with an image button that causes the loading of a different view in the multiview. All is fine up until this point. When the user hits the back button, they are taken back to the user control that contains the list view. The user then clicks on another image button to view different data and it returns to the detail user control using the same data as before. While debugging, I have seen that the item command event does not fire after hitting the back button.
I have tried replacing the multiview and putting each user control into separate panels. This did not change the outcome at all.
I have tried setting a cookie that expires 5 seconds after page load. When the user continues to the next page, then clicks back (and it has been longer than 5 seconds), I force the form to submit again. This loads the next control again instead of reloading the page.
I have tried setting the cacheability to no cache. This causes a "page expired" message and the user has to refresh the page. This is ugly for the user and definitely takes away from the user experience.
I am looking for the cleanest way for a user to click back and have the page reloaded so that the item command event fires correctly again.
The reason is that Back doesn't affect the Page Life Cycle. It's definitely because the page is cached and cached page doesn't execute on server. You can try this code to get rid of this issue.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
It took a lot of research to find this answer, so hopefully other people stumble upon this question and find my answer. I was astonished that I was actually able to find this. Ok, enough gloating.
Because the page does not postback when the user clicks the back button, the events are not fired correctly causing problems with the next page. What has to happen is you need to be able to handle the browser's navigation buttons (i.e. back and forward). To do this you have to set EnableHistory to true within the script manager and handle the Navigate event from the script manager. You can then reload the controls using the information you save in the state object.
I used these articles from Dino Esposito on DotNetSlackers.com as a reference. Server Side History Management and Client Side History Management
I have a gridview, getting data from sql server, there is an Edit link to get the detailed information for example, for a user from database.
this link open a new page with detailed information and when I click the updated button,I want to go back to the same page with that users informaton.
I set the page size to 10, it means I can see only 10 users per page,and if I click the edit link on page 25,and update the users info, I want to go back to page 25.
Should I use viewstate or gridview has any commnad to go back to the same page? the code is written in ASP.net C# sqlserver,
Thanks in advance
The gridview control will not provide this functionality.
Viewstate will only help persist data between postbacks of the same page (primarily).
Session state could be used to save the pagesize/pagenumber details onclick of the grideview edit before forwarding to the edit page. This can be re-processed back on loading of the view page.
My preference would be to store the values in the querystring. So on clicking edit, the pagesize and number are passed to the edit page (i.e edit.aspx?itemid=1&psize=10&pindx=25).
Then on finishing edit, the page number and size are based back to the view page for processing (view.aspx?psize=10&pindx=25)