When connecting your back-end code for ASP.Net to a SQL Server instance, always remember to include the SQL instance name in the connection string.
HOSTNAME\SQLEXPRESS (or another instance name)
<img src="./images/loading.gif" id="loader" style="visibility:hidden;" />
function showLoader()
{//*** Reload the image for IE ***document.getElementById('loader').src='./images/loader.gif';//*** Let's make the image visible ***document.getElementById('loader').style.visibility = 'visible';
}
Note that this is not needed for any browsers other than Internet Explorer (any that I know of at least). Firefox, Google Chrome, and Safari all ran the animated gif image during postback without freezing it.
To explain how the fix works, when a postback occurs in Internet Explorer, it stops all animations on the page, as mentioned. The trick to fixing this is to reload the animated gifs when the postback occurs. In the example this occurs in the first line of the JavaScript function, (document.getElementById('loader').src='./images/loader.gif');. Right there we just re-set the source for the object to the source for the same object on postback.
That's how it works. Any thoughts? Criticism? Motions to boycott Internet Explorer 7?
<!-- Text box that can't be empty -->
<input type="text" id="text" />Some Text
<br />
<!-- The file box to be validated -->
<input type="file" id="filebox" onclick="return validateText('text')"/>
<br />
<script>
function validateText( ObjectName )
{
// If there is nothing in the textbox...
if (document.getElementById(ObjectName).value == '')
{
alert('Please enter a value for Some Text before trying to select a file.')
return false;
}
// If textbox contains text...
else
{
alert('The text in Some Text is \"' + document.getElementById(ObjectName).value + '\". You may now select a file.');
return true;
}
}
</script>
Hopefully the HTML code is relatively self explanatory. <input type="file" id="filebox" onclick="return validateText('text')"/>
Typically in JavaScript, a return is not specified with function calls unless you want to be able to control the event (typically for code stability such as catching exceptions and stopping the code before it does harm) during the event.