Ask a Question related to ASP.NET General, Design and Development.
-
mg #1
Set focus on a TextBox
How can I set focus on a TextBox from within a button's
event handler.
mg Guest
-
Popup; show, take focus, wait for button action, give focus, hide
Hi. I've got a popup MC for displaying a message or asking a yes/no question that has to do the following on an event: - show and take focus... -
focus/lost focus of custom control
Hi new to .NET and have a question. What I want to do if have a custome control (contains a table grid of text boxes) and multiple instances... -
setting focus to textbox
Hello, Can someone tell me if/how I can set the focus to a textbox so when the page loads the cursor is placed in the textbox and the user can... -
Setting focus on TextBox using User Control
Private Sub SetFocus(ByVal FocusControl As Control) Dim Script As New System.Text.StringBuilder Dim ClientID As String = FocusControl. ClientID ... -
VERY STRANGE BUG? Adding a textbox control causes other textbox control to fail???
I've had this happen a few times too. I'm still not positive of what exactly causes it but all that's happening is the control that no longer... -
Karl Seguin #2
Re: Set focus on a TextBox
Here's a little script I got, and modified, from Charles Carroll, i think,
([url]www.learnasp.com[/url]).
Public Shared Sub SetFocus(ByVal ControlClientID As String, ByVal Page
As System.Web.UI.Page)
Dim scriptFunction As New System.Text.StringBuilder
Dim scriptClientId As String
scriptFunction.Append("<script language='javascript'>")
scriptFunction.Append("document.getElementById('")
scriptFunction.Append(ControlClientID)
scriptFunction.Append("').focus();")
scriptFunction.Append("</script>")
Page.RegisterStartupScript("focus", scriptFunction.ToString())
End Sub
ControlClientID is the ClientID property of your control (likely a textbox).
Karl
"mg" <mg@theworld.com> wrote in message
news:084701c34a0e$91af53d0$a401280a@phx.gbl...> How can I set focus on a TextBox from within a button's
> event handler.
Karl Seguin Guest
-
dj Bass #3
Re: Set focus on a TextBox
VB
Sub SetFocus(ByVal controlToFocus As Control)
Dim scriptFunction As New StringBuilder
Dim scriptClientId As String
scriptClientId = controlToFocus.ClientID
scriptFunction.Append("<script language='javascript'>")
scriptFunction.Append("document.getElementById('")
scriptFunction.Append(scriptClientId)
scriptFunction.Append("').focus();")
scriptFunction.Append("</script>")
RegisterStartupScript("focus", scriptFunction.ToString())
End Sub
C# (something like this)
Fucntion SetFocus(Control controlToFocus )
{
String scriptFunction;
String scriptClientId;
scriptClientId = controlToFocus.ClientID;
scriptFunction += ("<script language='javascript'>");
scriptFunction. += ("document.getElementById('");
scriptFunction. += (scriptClientId);
scriptFunction. += ("').focus();");
scriptFunction.Append("</script>");
RegisterStartupScript("focus", scriptFunction.ToString());
}
dj Bass Guest



Reply With Quote

