Below function is to automatically advance tab position from current text control to another text control as soon as soon as current textbox gets filled.
In below function
fromId : id of current text box
fromLen : length of current textBox
toId : id of target textBox
function autoAdvance(fromId, fromLen, toId, evt)
{
var textBox = document.getElementById(fromId);
var charCode = (evt.which) ? evt.which : event.keyCode;
len = textBox.value.length;
if (len == fromLen && ((charCode >= 48 && charCode <= 57) || (charCode >= 96 && charCode <= 105)))
{
document.getElementById(toId).focus();
}
}
Call this function on onKeyUp event of text box.
This blog is to share day to day programming problems that I face and their solutions I use.
Monday, October 25, 2010
Thursday, October 21, 2010
Open popup and refresh parent page on close popup, in ASP.NET with help of javascript
To open pop-up
//ButtonControl is id of button on whose click pop-up needs to be opened. Place below lines on pageLoad, rowDataBound or some other place as needed.
string popupPagePath = "http://www.ravigupta.in";
ButtonControl.Attributes.Add("onclick", "window.open('" + popupPagePath + "','','width=400, height=600'); return false;");
To close child window(pop-up) and then refresh the parent window.
Javascript code for closing child and refreshing parent
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
For using in ASP.NET, write below on event handler of control that initiates close of popup.
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "CloseWindow", "window.close(); if (window.opener && !window.opener.closed) { window.opener.location.reload(); }", true);
//ButtonControl is id of button on whose click pop-up needs to be opened. Place below lines on pageLoad, rowDataBound or some other place as needed.
string popupPagePath = "http://www.ravigupta.in";
ButtonControl.Attributes.Add("onclick", "window.open('" + popupPagePath + "','','width=400, height=600'); return false;");
To close child window(pop-up) and then refresh the parent window.
Javascript code for closing child and refreshing parent
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
For using in ASP.NET, write below on event handler of control that initiates close of popup.
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "CloseWindow", "window.close(); if (window.opener && !window.opener.closed) { window.opener.location.reload(); }", true);
This worked for me. Hope it helps you too.
Subscribe to:
Posts (Atom)
About Me
- Ravi Gupta
- Delhi, India
- Fun, music, travel and nature loving, always smiling, computer addict!!