I have several text boxes and drop-down lists in an AJAX Update
Panel. All user inputs have the Postback property set to True. After
I type something in the first input entry and press the "Tab" key how
can I set the focus to the next box after the postback? Please help!
Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
Re: Set Focus after Postback (vb.net newbie)
am 16.04.2008 15:12:30 von Eliyahu Goldin
Use ScriptManager.SetFocus (myControl).
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mel" wrote in message
news:45f475ee-1616-4b72-b34f-b7ba0890626b@m36g2000hse.google groups.com...
>I have several text boxes and drop-down lists in an AJAX Update
> Panel. All user inputs have the Postback property set to True. After
> I type something in the first input entry and press the "Tab" key how
> can I set the focus to the next box after the postback? Please help!
>
> Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
Re: Set Focus after Postback (vb.net newbie)
am 16.04.2008 15:41:14 von Mel
On Apr 16, 8:12 am, "Eliyahu Goldin" wrote:
> Use ScriptManager.SetFocus (myControl).
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> "Mel" wrote in message
>
> news:45f475ee-1616-4b72-b34f-b7ba0890626b@m36g2000hse.google groups.com...
>
> >I have several text boxes and drop-down lists in an AJAX Update
> > Panel. All user inputs have the Postback property set to True. After
> > I type something in the first input entry and press the "Tab" key how
> > can I set the focus to the next box after the postback? Please help!
>
> > Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
THANK YOU! I wish I would have posted my question yesterday...I spent
hours sifting the web for an answer. I had Page.SetFocus(MyControl)
instead of ScriptManager.SetFocus (myControl).
Code Snippet:
Protected Sub txtCustomer_TextChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles txtCustomer.TextChanged
'customer text box (1st text box on screen)
If rfvCustomer.IsValid = True Then
Session("ProjName") = txtCustomer.Text
Else
Session("ProjName") = Nothing
End If
Session("QRNextControl") = "2"
SetNextQRControl()
End Sub
Protected Sub SetNextQRControl()
Select Case Session("QRNextControl")
Case "2"
ScriptManager1.SetFocus(txtProjAddr1) 'address 1 text
box
Case "3"
ScriptManager1.SetFocus(txtProjAddr2) 'address 2 text
box
Case "4"
ScriptManager1.SetFocus(txtProjCity) 'city text box
Case "5"
ScriptManager1.SetFocus(ddlStAbrv) 'state text box
Case "6"
ScriptManager1.SetFocus(txtZip) 'zip text box
Case "7"
ScriptManager1.SetFocus(txtCusContact) 'customer
Contact text box
Case "8"
ScriptManager1.SetFocus(txtCusPhone) 'customer Phone
text box
Case "9"
ScriptManager1.SetFocus(txtProjName) 'project Name
text box
Case "10"
ScriptManager1.SetFocus(rblPriceAdj) 'price
Adjustment text box
End Select
Session("QRNextControl") = ""
End Sub
Re: Set Focus after Postback (vb.net newbie)
am 16.04.2008 15:45:57 von Eliyahu Goldin
>I wish I would have posted my question yesterday...I spent hours sifting
>the web for an answer.
This is the only way of getting experience known to me.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mel" wrote in message
news:8c13622e-c920-4226-9157-fe7359d10120@y21g2000hsf.google groups.com...
> On Apr 16, 8:12 am, "Eliyahu Goldin"
> wrote:
>> Use ScriptManager.SetFocus (myControl).
>>
>> --
>> Eliyahu Goldin,
>> Software Developer
>> Microsoft MVP
>> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>>
>> "Mel" wrote in message
>>
>> news:45f475ee-1616-4b72-b34f-b7ba0890626b@m36g2000hse.google groups.com...
>>
>> >I have several text boxes and drop-down lists in an AJAX Update
>> > Panel. All user inputs have the Postback property set to True. After
>> > I type something in the first input entry and press the "Tab" key how
>> > can I set the focus to the next box after the postback? Please help!
>>
>> > Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
>
> THANK YOU! I wish I would have posted my question yesterday...I spent
> hours sifting the web for an answer. I had Page.SetFocus(MyControl)
> instead of ScriptManager.SetFocus (myControl).
>
> Code Snippet:
> Protected Sub txtCustomer_TextChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles txtCustomer.TextChanged
> 'customer text box (1st text box on screen)
> If rfvCustomer.IsValid = True Then
> Session("ProjName") = txtCustomer.Text
> Else
> Session("ProjName") = Nothing
> End If
> Session("QRNextControl") = "2"
> SetNextQRControl()
> End Sub
> Protected Sub SetNextQRControl()
> Select Case Session("QRNextControl")
> Case "2"
> ScriptManager1.SetFocus(txtProjAddr1) 'address 1 text
> box
> Case "3"
> ScriptManager1.SetFocus(txtProjAddr2) 'address 2 text
> box
> Case "4"
> ScriptManager1.SetFocus(txtProjCity) 'city text box
> Case "5"
> ScriptManager1.SetFocus(ddlStAbrv) 'state text box
> Case "6"
> ScriptManager1.SetFocus(txtZip) 'zip text box
> Case "7"
> ScriptManager1.SetFocus(txtCusContact) 'customer
> Contact text box
> Case "8"
> ScriptManager1.SetFocus(txtCusPhone) 'customer Phone
> text box
> Case "9"
> ScriptManager1.SetFocus(txtProjName) 'project Name
> text box
> Case "10"
> ScriptManager1.SetFocus(rblPriceAdj) 'price
> Adjustment text box
> End Select
> Session("QRNextControl") = ""
> End Sub
Re: Set Focus after Postback (vb.net newbie)
am 16.04.2008 22:52:53 von Mel
On Apr 16, 8:45 am, "Eliyahu Goldin" wrote:
> >I wish I would have posted my question yesterday...I spent hours sifting
> >the web for an answer.
>
> This is the only way of getting experience known to me.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> "Mel" wrote in message
>
> news:8c13622e-c920-4226-9157-fe7359d10120@y21g2000hsf.google groups.com...
>
> > On Apr 16, 8:12 am, "Eliyahu Goldin"
> > wrote:
> >> Use ScriptManager.SetFocus (myControl).
>
> >> --
> >> Eliyahu Goldin,
> >> Software Developer
> >> Microsoft MVP
> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> >> "Mel" wrote in message
>
> >>news:45f475ee-1616-4b72-b34f-b7ba0890626b@m36g2000hse.goog legroups.com...
>
> >> >I have several text boxes and drop-down lists in an AJAX Update
> >> > Panel. All user inputs have the Postback property set to True. After
> >> > I type something in the first input entry and press the "Tab" key how
> >> > can I set the focus to the next box after the postback? Please help!
>
> >> > Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
>
> > THANK YOU! I wish I would have posted my question yesterday...I spent
> > hours sifting the web for an answer. I had Page.SetFocus(MyControl)
> > instead of ScriptManager.SetFocus (myControl).
>
> > Code Snippet:
> > Protected Sub txtCustomer_TextChanged(ByVal sender As Object,
> > ByVal e As System.EventArgs) Handles txtCustomer.TextChanged
> > 'customer text box (1st text box on screen)
> > If rfvCustomer.IsValid = True Then
> > Session("ProjName") = txtCustomer.Text
> > Else
> > Session("ProjName") = Nothing
> > End If
> > Session("QRNextControl") = "2"
> > SetNextQRControl()
> > End Sub
> > Protected Sub SetNextQRControl()
> > Select Case Session("QRNextControl")
> > Case "2"
> > ScriptManager1.SetFocus(txtProjAddr1) 'address 1 text
> > box
> > Case "3"
> > ScriptManager1.SetFocus(txtProjAddr2) 'address 2 text
> > box
> > Case "4"
> > ScriptManager1.SetFocus(txtProjCity) 'city text box
> > Case "5"
> > ScriptManager1.SetFocus(ddlStAbrv) 'state text box
> > Case "6"
> > ScriptManager1.SetFocus(txtZip) 'zip text box
> > Case "7"
> > ScriptManager1.SetFocus(txtCusContact) 'customer
> > Contact text box
> > Case "8"
> > ScriptManager1.SetFocus(txtCusPhone) 'customer Phone
> > text box
> > Case "9"
> > ScriptManager1.SetFocus(txtProjName) 'project Name
> > text box
> > Case "10"
> > ScriptManager1.SetFocus(rblPriceAdj) 'price
> > Adjustment text box
> > End Select
> > Session("QRNextControl") = ""
> > End Sub
It works great. One small glitch though.
Lets say there are 3 text boxes. If you type some data in the 1st
text box and then instead of pressing the tab key you click your mouse
in the 3rd text box, after the postback the cursor is sitting in the
2nd text box. Not the 3rd one.
Re: Set Focus after Postback (vb.net newbie)
am 17.04.2008 10:35:51 von Eliyahu Goldin
You can handle client side onfocus event to set a hidden text control to the
id of the element that got focus. On server side, you can set focus based on
the passed id as opposed to the session variable.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mel" wrote in message
news:8427bb66-c028-426d-bc11-18d9b3bcf209@m1g2000pre.googleg roups.com...
> On Apr 16, 8:45 am, "Eliyahu Goldin"
> wrote:
>> >I wish I would have posted my question yesterday...I spent hours sifting
>> >the web for an answer.
>>
>> This is the only way of getting experience known to me.
>>
>> --
>> Eliyahu Goldin,
>> Software Developer
>> Microsoft MVP
>> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>>
>> "Mel" wrote in message
>>
>> news:8c13622e-c920-4226-9157-fe7359d10120@y21g2000hsf.google groups.com...
>>
>> > On Apr 16, 8:12 am, "Eliyahu Goldin"
>> > wrote:
>> >> Use ScriptManager.SetFocus (myControl).
>>
>> >> --
>> >> Eliyahu Goldin,
>> >> Software Developer
>> >> Microsoft MVP
>> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>>
>> >> "Mel" wrote in message
>>
>> >>news:45f475ee-1616-4b72-b34f-b7ba0890626b@m36g2000hse.goog legroups.com...
>>
>> >> >I have several text boxes and drop-down lists in an AJAX Update
>> >> > Panel. All user inputs have the Postback property set to True.
>> >> > After
>> >> > I type something in the first input entry and press the "Tab" key
>> >> > how
>> >> > can I set the focus to the next box after the postback? Please
>> >> > help!
>>
>> >> > Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
>>
>> > THANK YOU! I wish I would have posted my question yesterday...I spent
>> > hours sifting the web for an answer. I had Page.SetFocus(MyControl)
>> > instead of ScriptManager.SetFocus (myControl).
>>
>> > Code Snippet:
>> > Protected Sub txtCustomer_TextChanged(ByVal sender As Object,
>> > ByVal e As System.EventArgs) Handles txtCustomer.TextChanged
>> > 'customer text box (1st text box on screen)
>> > If rfvCustomer.IsValid = True Then
>> > Session("ProjName") = txtCustomer.Text
>> > Else
>> > Session("ProjName") = Nothing
>> > End If
>> > Session("QRNextControl") = "2"
>> > SetNextQRControl()
>> > End Sub
>> > Protected Sub SetNextQRControl()
>> > Select Case Session("QRNextControl")
>> > Case "2"
>> > ScriptManager1.SetFocus(txtProjAddr1) 'address 1 text
>> > box
>> > Case "3"
>> > ScriptManager1.SetFocus(txtProjAddr2) 'address 2 text
>> > box
>> > Case "4"
>> > ScriptManager1.SetFocus(txtProjCity) 'city text box
>> > Case "5"
>> > ScriptManager1.SetFocus(ddlStAbrv) 'state text box
>> > Case "6"
>> > ScriptManager1.SetFocus(txtZip) 'zip text box
>> > Case "7"
>> > ScriptManager1.SetFocus(txtCusContact) 'customer
>> > Contact text box
>> > Case "8"
>> > ScriptManager1.SetFocus(txtCusPhone) 'customer Phone
>> > text box
>> > Case "9"
>> > ScriptManager1.SetFocus(txtProjName) 'project Name
>> > text box
>> > Case "10"
>> > ScriptManager1.SetFocus(rblPriceAdj) 'price
>> > Adjustment text box
>> > End Select
>> > Session("QRNextControl") = ""
>> > End Sub
>
> It works great. One small glitch though.
> Lets say there are 3 text boxes. If you type some data in the 1st
> text box and then instead of pressing the tab key you click your mouse
> in the 3rd text box, after the postback the cursor is sitting in the
> 2nd text box. Not the 3rd one.
Re: Set Focus after Postback (vb.net newbie)
am 17.04.2008 15:44:38 von Mel
On Apr 17, 3:35 am, "Eliyahu Goldin" wrote:
> You can handle client side onfocus event to set a hidden text control to the
> id of the element that got focus. On server side, you can set focus based on
> the passed id as opposed to the session variable.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> "Mel" wrote in message
>
> news:8427bb66-c028-426d-bc11-18d9b3bcf209@m1g2000pre.googleg roups.com...
>
> > On Apr 16, 8:45 am, "Eliyahu Goldin"
> > wrote:
> >> >I wish I would have posted my question yesterday...I spent hours sifting
> >> >the web for an answer.
>
> >> This is the only way of getting experience known to me.
>
> >> --
> >> Eliyahu Goldin,
> >> Software Developer
> >> Microsoft MVP
> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> >> "Mel" wrote in message
>
> >>news:8c13622e-c920-4226-9157-fe7359d10120@y21g2000hsf.goog legroups.com...
>
> >> > On Apr 16, 8:12 am, "Eliyahu Goldin"
> >> > wrote:
> >> >> Use ScriptManager.SetFocus (myControl).
>
> >> >> --
> >> >> Eliyahu Goldin,
> >> >> Software Developer
> >> >> Microsoft MVP
> >> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> >> >> "Mel" wrote in message
>
> >> >>news:45f475ee-1616-4b72-b34f-b7ba0890626b@m36g2000hse.goog legroups.com...
>
> >> >> >I have several text boxes and drop-down lists in an AJAX Update
> >> >> > Panel. All user inputs have the Postback property set to True.
> >> >> > After
> >> >> > I type something in the first input entry and press the "Tab" key
> >> >> > how
> >> >> > can I set the focus to the next box after the postback? Please
> >> >> > help!
>
> >> >> > Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
>
> >> > THANK YOU! I wish I would have posted my question yesterday...I spent
> >> > hours sifting the web for an answer. I had Page.SetFocus(MyControl)
> >> > instead of ScriptManager.SetFocus (myControl).
>
> >> > Code Snippet:
> >> > Protected Sub txtCustomer_TextChanged(ByVal sender As Object,
> >> > ByVal e As System.EventArgs) Handles txtCustomer.TextChanged
> >> > 'customer text box (1st text box on screen)
> >> > If rfvCustomer.IsValid = True Then
> >> > Session("ProjName") = txtCustomer.Text
> >> > Else
> >> > Session("ProjName") = Nothing
> >> > End If
> >> > Session("QRNextControl") = "2"
> >> > SetNextQRControl()
> >> > End Sub
> >> > Protected Sub SetNextQRControl()
> >> > Select Case Session("QRNextControl")
> >> > Case "2"
> >> > ScriptManager1.SetFocus(txtProjAddr1) 'address 1 text
> >> > box
> >> > Case "3"
> >> > ScriptManager1.SetFocus(txtProjAddr2) 'address 2 text
> >> > box
> >> > Case "4"
> >> > ScriptManager1.SetFocus(txtProjCity) 'city text box
> >> > Case "5"
> >> > ScriptManager1.SetFocus(ddlStAbrv) 'state text box
> >> > Case "6"
> >> > ScriptManager1.SetFocus(txtZip) 'zip text box
> >> > Case "7"
> >> > ScriptManager1.SetFocus(txtCusContact) 'customer
> >> > Contact text box
> >> > Case "8"
> >> > ScriptManager1.SetFocus(txtCusPhone) 'customer Phone
> >> > text box
> >> > Case "9"
> >> > ScriptManager1.SetFocus(txtProjName) 'project Name
> >> > text box
> >> > Case "10"
> >> > ScriptManager1.SetFocus(rblPriceAdj) 'price
> >> > Adjustment text box
> >> > End Select
> >> > Session("QRNextControl") = ""
> >> > End Sub
>
> > It works great. One small glitch though.
> > Lets say there are 3 text boxes. If you type some data in the 1st
> > text box and then instead of pressing the tab key you click your mouse
> > in the 3rd text box, after the postback the cursor is sitting in the
> > 2nd text box. Not the 3rd one.
Sorry to be a pain. I am using a Textbox control. Will I need to use
a different control instead to get an OnFocus method?
Re: Set Focus after Postback (vb.net newbie)
am 17.04.2008 15:57:29 von Eliyahu Goldin
No, you can attach a client-side event handler like
myTextBox.Attributes["onfocus"] = "gotFocus(this)";
and in .aspx file:
and in javascript
function gotFocus(control)
{
myForm.inhControlWithFocus.value = control.Id;
}
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mel" wrote in message
news:3ab787f5-0b1f-41a7-9e6c-afa1202647af@c65g2000hsa.google groups.com...
> On Apr 17, 3:35 am, "Eliyahu Goldin"
> wrote:
>> You can handle client side onfocus event to set a hidden text control to
>> the
>> id of the element that got focus. On server side, you can set focus based
>> on
>> the passed id as opposed to the session variable.
>>
>> --
>> Eliyahu Goldin,
>> Software Developer
>> Microsoft MVP
>> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>>
>> "Mel" wrote in message
>>
>> news:8427bb66-c028-426d-bc11-18d9b3bcf209@m1g2000pre.googleg roups.com...
>>
>> > On Apr 16, 8:45 am, "Eliyahu Goldin"
>> > wrote:
>> >> >I wish I would have posted my question yesterday...I spent hours
>> >> >sifting
>> >> >the web for an answer.
>>
>> >> This is the only way of getting experience known to me.
>>
>> >> --
>> >> Eliyahu Goldin,
>> >> Software Developer
>> >> Microsoft MVP
>> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>>
>> >> "Mel" wrote in message
>>
>> >>news:8c13622e-c920-4226-9157-fe7359d10120@y21g2000hsf.goog legroups.com...
>>
>> >> > On Apr 16, 8:12 am, "Eliyahu Goldin"
>> >> > wrote:
>> >> >> Use ScriptManager.SetFocus (myControl).
>>
>> >> >> --
>> >> >> Eliyahu Goldin,
>> >> >> Software Developer
>> >> >> Microsoft MVP
>> >> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>>
>> >> >> "Mel" wrote in message
>>
>> >> >>news:45f475ee-1616-4b72-b34f-b7ba0890626b@m36g2000hse.goog legroups.com...
>>
>> >> >> >I have several text boxes and drop-down lists in an AJAX Update
>> >> >> > Panel. All user inputs have the Postback property set to True.
>> >> >> > After
>> >> >> > I type something in the first input entry and press the "Tab" key
>> >> >> > how
>> >> >> > can I set the focus to the next box after the postback? Please
>> >> >> > help!
>>
>> >> >> > Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
>>
>> >> > THANK YOU! I wish I would have posted my question yesterday...I
>> >> > spent
>> >> > hours sifting the web for an answer. I had Page.SetFocus(MyControl)
>> >> > instead of ScriptManager.SetFocus (myControl).
>>
>> >> > Code Snippet:
>> >> > Protected Sub txtCustomer_TextChanged(ByVal sender As Object,
>> >> > ByVal e As System.EventArgs) Handles txtCustomer.TextChanged
>> >> > 'customer text box (1st text box on screen)
>> >> > If rfvCustomer.IsValid = True Then
>> >> > Session("ProjName") = txtCustomer.Text
>> >> > Else
>> >> > Session("ProjName") = Nothing
>> >> > End If
>> >> > Session("QRNextControl") = "2"
>> >> > SetNextQRControl()
>> >> > End Sub
>> >> > Protected Sub SetNextQRControl()
>> >> > Select Case Session("QRNextControl")
>> >> > Case "2"
>> >> > ScriptManager1.SetFocus(txtProjAddr1) 'address 1 text
>> >> > box
>> >> > Case "3"
>> >> > ScriptManager1.SetFocus(txtProjAddr2) 'address 2 text
>> >> > box
>> >> > Case "4"
>> >> > ScriptManager1.SetFocus(txtProjCity) 'city text box
>> >> > Case "5"
>> >> > ScriptManager1.SetFocus(ddlStAbrv) 'state text box
>> >> > Case "6"
>> >> > ScriptManager1.SetFocus(txtZip) 'zip text box
>> >> > Case "7"
>> >> > ScriptManager1.SetFocus(txtCusContact) 'customer
>> >> > Contact text box
>> >> > Case "8"
>> >> > ScriptManager1.SetFocus(txtCusPhone) 'customer Phone
>> >> > text box
>> >> > Case "9"
>> >> > ScriptManager1.SetFocus(txtProjName) 'project Name
>> >> > text box
>> >> > Case "10"
>> >> > ScriptManager1.SetFocus(rblPriceAdj) 'price
>> >> > Adjustment text box
>> >> > End Select
>> >> > Session("QRNextControl") = ""
>> >> > End Sub
>>
>> > It works great. One small glitch though.
>> > Lets say there are 3 text boxes. If you type some data in the 1st
>> > text box and then instead of pressing the tab key you click your mouse
>> > in the 3rd text box, after the postback the cursor is sitting in the
>> > 2nd text box. Not the 3rd one.
>
> Sorry to be a pain. I am using a Textbox control. Will I need to use
> a different control instead to get an OnFocus method?
Re: Set Focus after Postback (vb.net newbie)
am 17.04.2008 18:25:39 von Mel
On Apr 17, 8:57 am, "Eliyahu Goldin" wrote:
> No, you can attach a client-side event handler like
> myTextBox.Attributes["onfocus"] = "gotFocus(this)";
>
> and in .aspx file:
>
>
> and in javascript
> function gotFocus(control)
> {
> myForm.inhControlWithFocus.value = control.Id;
>
> }
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> "Mel" wrote in message
>
> news:3ab787f5-0b1f-41a7-9e6c-afa1202647af@c65g2000hsa.google groups.com...
>
> > On Apr 17, 3:35 am, "Eliyahu Goldin"
> > wrote:
> >> You can handle client side onfocus event to set a hidden text control to
> >> the
> >> id of the element that got focus. On server side, you can set focus based
> >> on
> >> the passed id as opposed to the session variable.
>
> >> --
> >> Eliyahu Goldin,
> >> Software Developer
> >> Microsoft MVP
> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> >> "Mel" wrote in message
>
> >>news:8427bb66-c028-426d-bc11-18d9b3bcf209@m1g2000pre.googl egroups.com...
>
> >> > On Apr 16, 8:45 am, "Eliyahu Goldin"
> >> > wrote:
> >> >> >I wish I would have posted my question yesterday...I spent hours
> >> >> >sifting
> >> >> >the web for an answer.
>
> >> >> This is the only way of getting experience known to me.
>
> >> >> --
> >> >> Eliyahu Goldin,
> >> >> Software Developer
> >> >> Microsoft MVP
> >> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> >> >> "Mel" wrote in message
>
> >> >>news:8c13622e-c920-4226-9157-fe7359d10120@y21g2000hsf.goog legroups.com...
>
> >> >> > On Apr 16, 8:12 am, "Eliyahu Goldin"
> >> >> > wrote:
> >> >> >> Use ScriptManager.SetFocus (myControl).
>
> >> >> >> --
> >> >> >> Eliyahu Goldin,
> >> >> >> Software Developer
> >> >> >> Microsoft MVP
> >> >> >> [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> >> >> >> "Mel" wrote in message
>
> >> >> >>news:45f475ee-1616-4b72-b34f-b7ba0890626b@m36g2000hse.goog legroups.com...
>
> >> >> >> >I have several text boxes and drop-down lists in an AJAX Update
> >> >> >> > Panel. All user inputs have the Postback property set to True.
> >> >> >> > After
> >> >> >> > I type something in the first input entry and press the "Tab" key
> >> >> >> > how
> >> >> >> > can I set the focus to the next box after the postback? Please
> >> >> >> > help!
>
> >> >> >> > Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
>
> >> >> > THANK YOU! I wish I would have posted my question yesterday...I
> >> >> > spent
> >> >> > hours sifting the web for an answer. I had Page.SetFocus(MyControl)
> >> >> > instead of ScriptManager.SetFocus (myControl).
>
> >> >> > Code Snippet:
> >> >> > Protected Sub txtCustomer_TextChanged(ByVal sender As Object,
> >> >> > ByVal e As System.EventArgs) Handles txtCustomer.TextChanged
> >> >> > 'customer text box (1st text box on screen)
> >> >> > If rfvCustomer.IsValid = True Then
> >> >> > Session("ProjName") = txtCustomer.Text
> >> >> > Else
> >> >> > Session("ProjName") = Nothing
> >> >> > End If
> >> >> > Session("QRNextControl") = "2"
> >> >> > SetNextQRControl()
> >> >> > End Sub
> >> >> > Protected Sub SetNextQRControl()
> >> >> > Select Case Session("QRNextControl")
> >> >> > Case "2"
> >> >> > ScriptManager1.SetFocus(txtProjAddr1) 'address 1 text
> >> >> > box
> >> >> > Case "3"
> >> >> > ScriptManager1.SetFocus(txtProjAddr2) 'address 2 text
> >> >> > box
> >> >> > Case "4"
> >> >> > ScriptManager1.SetFocus(txtProjCity) 'city text box
> >> >> > Case "5"
> >> >> > ScriptManager1.SetFocus(ddlStAbrv) 'state text box
> >> >> > Case "6"
> >> >> > ScriptManager1.SetFocus(txtZip) 'zip text box
> >> >> > Case "7"
> >> >> > ScriptManager1.SetFocus(txtCusContact) 'customer
> >> >> > Contact text box
> >> >> > Case "8"
> >> >> > ScriptManager1.SetFocus(txtCusPhone) 'customer Phone
> >> >> > text box
> >> >> > Case "9"
> >> >> > ScriptManager1.SetFocus(txtProjName) 'project Name
> >> >> > text box
> >> >> > Case "10"
> >> >> > ScriptManager1.SetFocus(rblPriceAdj) 'price
> >> >> > Adjustment text box
> >> >> > End Select
> >> >> > Session("QRNextControl") = ""
> >> >> > End Sub
>
> >> > It works great. One small glitch though.
> >> > Lets say there are 3 text boxes. If you type some data in the 1st
> >> > text box and then instead of pressing the tab key you click your mouse
> >> > in the 3rd text box, after the postback the cursor is sitting in the
> >> > 2nd text box. Not the 3rd one.
>
> > Sorry to be a pain. I am using a Textbox control. Will I need to use
> > a different control instead to get an OnFocus method?
The hidden text box always says "undefined". I am doing something
wrong.
------------------------------------------------------------ ------------------------------------------------------------ ------------------------------------------------------------ -------------------
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
TextBox1.Attributes("onfocus") = "gotFocus(this)"
TextBox2.Attributes("onfocus") = "gotFocus(this)"
TextBox3.Attributes("onfocus") = "gotFocus(this)"
End Sub
Protected Sub SetNextQRControl()
ScriptManager1.SetFocus(inhControlWithFocus.ID)
End Sub
Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e
As System.EventArgs)
'Session("QRNextControl") = 2
SetNextQRControl()
End Sub
Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e
As System.EventArgs)
'Session("QRNextControl") = 3
SetNextQRControl()
End Sub
Protected Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e
As System.EventArgs)
'Session("QRNextControl") = 1
SetNextQRControl()
End Sub
End Class