I'm working on a project to syndicate library content with RSS.... and learn .NET, C#, and AJAX

Monday, July 16, 2007

Focus()

So, setting the focus was actually pretty easy! I put this in my Page_Load method:

string controlName = Request.Params.Get("__EVENTTARGET");
if (controlName == "create_lbtn") {
txt_listtitle.Focus(); }
else if (controlName.Substring(0,9) == "edit_link") { //we have many of these controls, any will do.
txt_search_rdb.Focus(); }

else { welcome_lbtn.Focus(); }

So, now the Delete button does not fire on refresh -- nor any other button. And, as it turned out, JavaScript was not even necessary!

No comments: