Monday, June 18, 2012

Web apps–disabling the back button

Sometimes when you create web-applications (eg: ASP.Net, etc), you need to disable the use of the browser back button. Now there is no way you can actually disable the browser back button using JavaScript, so you could create a new window without toolbars, etc.

But another way you can do it is by inserting the following code into the page that you don’t wish to support the ability to go back to:

<head>
<script type="text/javascript">
  window.history.go(1)
</script>
</head>

How does it work?

go(1), makes the browser go forward to the next page in the browser history. The first time you visit a page, your browser history does not have a page to go to, so go(1) does nothing. But if you try and go back to a page on which the above code exists, then because you have a page in history, go(1) works and takes you back to the page that you were on. Simple and effective.

Note: I came across this solution on the Internet and cant find the link anymore.

Wednesday, June 06, 2012

Tip for determining connection strings

Here is a nice little cheat for setting up a connection string:

  1. Create a text file and name it so that it has a file extension of “udl”
  2. Double click the file: the “Data link properties” dialog will open.
    image
  3. Setup your connection parameters by going through all the tabs in the dialog.
  4. Click ok to save the connection settings.
  5. Open the UDL file in notepad. Voila, you have your connection string!