Monday 16 April 2012

UPLOADING A FILE

FILE UPLOADING:


string filename = "filename from Database";
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
string aaa = Server.MapPath("~/SavedFolder/" + filename);
Response.TransmitFile(Server.MapPath("~/SavedFolder/" + filename));
Response.End();

caps lock detection

DETECTING CAPS LOCK ON IN A TEXTBOX

In the textbox keypress event a function is called :
<div><asp:TextBox ID="TextBox1" runat="server" onKeypress="isCapLockOn(event)"></asp:TextBox><
</

Now the function is defined as follows :


<script language="javascript" type="text/javascript">



|| ((charKeyCode >= 97 && charKeyCode <= 122) && shiftKey)) {
document.getElementById(
}

document.getElementById(
}
}
function isCapLockOn(e) {var charKeyCode = e.keyCode ? e.keyCode : e.which;var shiftKey = e.shiftKey ? e.shiftKey : ((charKeyCode == 16) ? true : false);if (((charKeyCode >= 65 && charKeyCode <= 90) && !shiftKey)'keyStage').innerHTML = "Caps lock : <b>On</b>";else {'keyStage').innerHTML = "Caps lock : <b>Off</b>";</script>
 
div id="keyStage" style="color:Red;font-size:80%;"></div>div>

Monday 2 April 2012

Disable the back button in asp .net

Just write the following code in the source code of the page where you do not want to come back once redirected to another page :



<script type = "text/javascript" >

function preventBack() { window.history.forward(); }

setTimeout("preventBack()", 0);

window.onunload = function() { null };


EXPLANATION :

Javascript History forward function loads the next URL saved in the history array list of URLs in the web browser history visited by the user. History forward function of javascript performs the same action as the forward arrow button of the web browser. But remember that javascript history forward function loads the page from the cached version of the web page stores at the client side

The Javascript setTimeout() function allows code to be executed a set time after some trigger, such as when the page has loaded or a button is pressed.The setTimeout() function takes two parameters: 1) the function or code to call and 2) the number of milliseconds to wait before executing the code/function