Home All Groups Group Topic Archive Search About

Can I set initial focus from server-side into textbox?

Author
4 May 2005 4:22 AM
Kent P. Iler
Hi,

I am showing/hiding a variety of panels that have different text boxes via
code-behind functions.  Depending on the condition, I would like to have the
focus be set on a specific text box.  However, all examples I've seen do
this from the client side.

Does anyone have a way to easily to specify the textbox to focus on from a
code-behind function?  My guess is it will have to be some combination of
server-side and client-side coding.

Any help would be appreciated.

Thanks!

-- Kent Iler
----------------------------------------------------------------------
kent@iler.NOSPAM.com
Please CC: all replies via e-mail
Remove .NOSPAM from e-mail address

Author
4 May 2005 5:50 AM
mavisahdas
Hi Kent,

Yeah you can bring to the focus to some controls based on some condition. I
believe you know how to bring the focus to a control using java script. What
you need to do here is make that script to trigger from the code behind file.

There are two ways to running the script from the code behind file.

1. Printing the script using response.write.

eg. Response.Write("<script>text1.focus()</script>")

2. Using  Page.RegisterStartupScript

Page.RegisterStartupScript("foc", "text1.focus()")

Page.RegisterStartupScript will execute the script.

With regards,

Sadha Sivam S,
Microsoft Community Star,
Sr. Software Engineer,
Aspire Systems,
www.dotnetspider.com


Show quoteHide quote
"Kent P. Iler" wrote:

> Hi,
>
> I am showing/hiding a variety of panels that have different text boxes via
> code-behind functions.  Depending on the condition, I would like to have the
> focus be set on a specific text box.  However, all examples I've seen do
> this from the client side.
>
> Does anyone have a way to easily to specify the textbox to focus on from a
> code-behind function?  My guess is it will have to be some combination of
> server-side and client-side coding.
>
> Any help would be appreciated.
>
> Thanks!
>
> -- Kent Iler
> ----------------------------------------------------------------------
> kent@iler.NOSPAM.com
> Please CC: all replies via e-mail
> Remove .NOSPAM from e-mail address
>
>
>
Author
4 May 2005 5:52 AM
Steve C. Orr [MVP, MCSD]
Something basic like this should work:

Response.Write "<script language = javascript>"& MyTextBox.ClientID &
".focus()</script>"

Here is an even slicker approach:
http://SteveOrr.net/faq/2in1.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


Show quoteHide quote
"Kent P. Iler" <kent@iler.NOSPAM.com> wrote in message
news:NrmdnTGa65CB0-XfRVn-gA@comcast.com...
> Hi,
>
> I am showing/hiding a variety of panels that have different text boxes via
> code-behind functions.  Depending on the condition, I would like to have
> the focus be set on a specific text box.  However, all examples I've seen
> do this from the client side.
>
> Does anyone have a way to easily to specify the textbox to focus on from a
> code-behind function?  My guess is it will have to be some combination of
> server-side and client-side coding.
>
> Any help would be appreciated.
>
> Thanks!
>
> -- Kent Iler
> ----------------------------------------------------------------------
> kent@iler.NOSPAM.com
> Please CC: all replies via e-mail
> Remove .NOSPAM from e-mail address
>
Author
4 May 2005 5:56 AM
mavisahdas
Hi Kent,

You can make use form Data Format string property of the grid columns to
format the date.

For more input Refer http://www.dotnetspider.com/technology/kbpages/384.aspx.

With regards,

Sadha Sivam S,
Microsoft Community Star,
Sr. Engineer,
Aspire Systems,
www.dotnetspider.com

Show quoteHide quote
"Kent P. Iler" wrote:

> Hi,
>
> I am showing/hiding a variety of panels that have different text boxes via
> code-behind functions.  Depending on the condition, I would like to have the
> focus be set on a specific text box.  However, all examples I've seen do
> this from the client side.
>
> Does anyone have a way to easily to specify the textbox to focus on from a
> code-behind function?  My guess is it will have to be some combination of
> server-side and client-side coding.
>
> Any help would be appreciated.
>
> Thanks!
>
> -- Kent Iler
> ----------------------------------------------------------------------
> kent@iler.NOSPAM.com
> Please CC: all replies via e-mail
> Remove .NOSPAM from e-mail address
>
>
>