Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Mobile / October 2005

Tip: Looking for answers? Try searching our database.

SetFocus

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
José Araujo - 05 Oct 2005 00:12 GMT
Hi,

I am trying to set my MobileApp to set the focus to a given component.

For regular webforms it seems that the classic solution is to use the code
below, which in turn inserts JavaScript code in the page that does the job.

I am trying to use the same in my page, but it doesn't work. It doesn't
insert any code in the resulting HTML page (when you use view source in IE).

Any ideas? Thanks, José Araujo.

public static void SetFocus(Control control)
{
   StringBuilder sb = new StringBuilder();

   sb.Append("\r\n<script language='JavaScript'>\r\n");
   sb.Append("<!--\r\n");
   sb.Append("function SetFocus()\r\n");
   sb.Append("{\r\n");
   sb.Append("\tdocument.");

   Control p = control.Parent;
   while (!(p is System.Web.UI.HtmlControls.HtmlForm)) p = p.Parent;

   sb.Append(p.ClientID);
   sb.Append("['");
   sb.Append(control.UniqueID);
   sb.Append("'].focus();\r\n");
   sb.Append("}\r\n");
   sb.Append("window.onload = SetFocus;\r\n");
   sb.Append("// -->\r\n");
   sb.Append("</script>");

   control.Page.RegisterClientScriptBlock("SetFocus", sb.ToString());
}
José Araujo - 07 Oct 2005 21:25 GMT
I resolved this. I wrote my own server control that just renders script
code.

> Hi,
>
[quoted text clipped - 34 lines]
>    control.Page.RegisterClientScriptBlock("SetFocus", sb.ToString());
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.