Getting focus on Silverlight control on load

When we host a Silverlight application inside a ASP.Net page and set a focus on a control inside Silverlight application, we would except the control to get the focus, but that does not happen automatically. One way it can be achieved by adding a on load script to the Silverlight object and make the Silverlight object get the focus.

<param name=”onLoad” value=”onLoad” />

function onLoad(sender, args)

{

   var silverlightObject = document.getElementById(“silverlightObject”);

   if (silverlightObject != null)

      silverlightObject.focus();

}

make sure you name the Silverlight object as ‘silverlightObject’ or replace the onload script with the name of the silverlight object.

Technorati Tags: ,

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s