+ Start a Discussion
rahul2526rahul2526 

Set focus on a control on visualforce page load through controller class

Hi...

 

I am trying to set focus to a specified textbox through its controller class(as it is requirement) ...

 

For this in asp we have like "Page.RegisterStartupScript()"...

for eg..

 

private void SetFocus(String controlID)
{
  // Build the JavaScript String
  System.Text.StringBuilder sb = new System.Text.StringBuilder();
  sb.Append("<script language='javascript'>");
  sb.Append("document.getElementById('");
  sb.Append(controlID);
  sb.Append("').focus()");
  sb.Append("</script>")
 
  // Register the script code with the page.
  Page.RegisterStartupScript("FocusScript", sb.ToString());
}

 

 

Is there any method in apex in Force.com to register a javascript on current page through apex code...

 

please reply asap...

 

Thank you!!!

rahul2526rahul2526

Hi....

 

I get the solution....

anyways...

thanks...

NikhilNikhil

Hi Can you please share the solution u got.