[.NetIndia] Re: How to set focus on a page ..
Reply
![]() |
|
From:
![]() AnupShinde
|
Hi,
Use this method to set focus to your web-controls. Hopefully, it should work fine in all cases
-----------
Private Function SetFocus(ByRef ctrl As System.Web.UI.WebControls.WebControl) Dim strScript As String
If (ctrl.Enabled And ctrl.Visible) Then strScript = " <script language=_javascript_> document.forms[0]." + TextBox2.ClientID + ".focus(); </script>" Page.RegisterStartupScript(ctrl.ID + "_focus", strScript) End If End Function
-----------
Call it like: SetFocus(TextBox1)
Regards, Anup Shinde
On 9/29/05, Selvakumar <[EMAIL PROTECTED]> wrote: > > Hiii, > Put a ASP.Net Label control and set the font color to the label > as the background color of the form.Now from CODE set the value of the > label to the name of the control to which Focus has to be made!!!. > > Add the following script to the end of the BODY tag of the web page.. > <script> > //set the focus to the control > if (window.document.all("LabelName").value != "") > { > window.document.all(window.document.all("LabelName").value).focus(); > window.document.all("LabelName").value = ""; > } > </script> > > Try it let me know if u have any doubts..This is what i've done for > focus problems... > > > > Regards, > Selva.. >
|
|
View other groups in this category.
![]() |
To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.
Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.
If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.
|
|