function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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.