Monday, September 04, 2006

Javascript focus and functions with textBox

Set Focus function on server side code (just pass in the string of the control name)

protected void setFocus( String ctrl )
string s = "[SCRIPT language='javascript']document.Form1.Editor1_" + ctrl + ".focus();[/SCRIPT]";
Page.RegisterStartupScript( "focus", s );


Function on server side code to assign javascript event to a particular ASP.NET control (Change the details passed to JavaScript function for each call)

txtStartDateDay.Attributes.Add("onkeyup", "SetFocusX('Editor1_txtStartDateDay','Editor1_txtStartDateMonth')");

In the HTML JavaScript function (checks the lenght of the field if two sets focus to the next)

function SetFocusX(oField, oField2)
var strText = document.getElementById(oField).value;
if(strText.length == 2)

1 comment:

Anonymous said...

discount zithromax
For Community Acquired Pneumonia, the recommended dose is 10 mg/kg and then followed by 5 mg/kg on the second day to the fifth day.
[url=]zithromax azithromycin[/url]
It is also available in 500 mg tablet with the same description as the 250 mg tablet. - buy azithromycin
Since this drug belongs to Pregnancy category B, there have been no evidence that it will not farm the fetus.