Set focus inside a repeater

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using a repeater for editing, but having a devil of a time setting the
focus to a textbox inside the repeater. Does anyone have an example of how to
do this?
 
Try something like:

TextBox TextBox1 = (TextBox) Repeater1.FindControl("TextBox1");
TextBox1.Focus();

Since it is a repeater, you may have to go to the Row level before invoking
the FindControl method.
 
Great! I had worked around it with tabindexing but I'll give this a shot.
--
Thanks,

CGW


Christopher Reed said:
Try something like:

TextBox TextBox1 = (TextBox) Repeater1.FindControl("TextBox1");
TextBox1.Focus();

Since it is a repeater, you may have to go to the Row level before invoking
the FindControl method.
 
Didn't work. Focus, Focused, etc. don't seemed to be recogognized as members.
--
Thanks,

CGW


Christopher Reed said:
Try something like:

TextBox TextBox1 = (TextBox) Repeater1.FindControl("TextBox1");
TextBox1.Focus();

Since it is a repeater, you may have to go to the Row level before invoking
the FindControl method.
 
Are you using 1.1 or 2.0?
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

CGW said:
Didn't work. Focus, Focused, etc. don't seemed to be recogognized as
members.
 
Which explains things since my suggestions are for 2.0. With 1.1, you'll
have to figure out what the control is and use a dynamically created
Javascript to set focus. You can use something like the
Page.RegisterClientScriptBlock method to add your script dynamically.
 
Back
Top