Monday, March 26, 2012
set focus
button...
can anyone tell me how can i setfocus of textbox when page is load?
should i do that by java script?please send me coding how to do that?
and can anyone tell me how can i send mail to the group of user?and how
can i add user in the vb.net?
i am developing one web application for one designing institute and
they want mailing facility so if i send one mail then all the member of
institute get that mail and for that i am supposed to create one group
for that...and any member can leave any time and one can be a member
of the institute so no of user are not fixed so tell me how can i do?i
did coding for sending one mail to the single user but i don't know how
to do for the group?should i take one array?please send me the code
snippet and it's better if it's in visual basic and not asp..thanks a
lot in advance
NilIf you are in 2.0, use method SetFocus.
In 1.1 you need to do it in with javascript in the body's onload event.
And it is always a good idea to post different questions in separate
threads.
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"nil" <NileshThakker786@.gmail.com> wrote in message
news:1165315092.234534.218860@.73g2000cwn.googlegroups.com...
> hi..suppose there is only one textbox in the form and one command
> button...
> can anyone tell me how can i setfocus of textbox when page is load?
> should i do that by java script?please send me coding how to do that?
>
> and can anyone tell me how can i send mail to the group of user?and how
> can i add user in the vb.net?
> i am developing one web application for one designing institute and
> they want mailing facility so if i send one mail then all the member of
> institute get that mail and for that i am supposed to create one group
> for that...and any member can leave any time and one can be a member
> of the institute so no of user are not fixed so tell me how can i do?i
> did coding for sending one mail to the single user but i don't know how
> to do for the group?should i take one array?please send me the code
> snippet and it's better if it's in visual basic and not asp..thanks a
> lot in advance
>
> Nil
>
Nil,
Eliyahu is right on. Here's what the javascript would look like if you are
using the 1.1 framework:
<script type='text/javascript'>
textbox = document. getElementById('[Replacewithnameofcontro
l]');
if (textbox)
{
textbox.focus();
}
else
{
// The textbox doesn't exist you have an error
}
</script>
If you are using the 2.0 framework you can do what Eliyahu mentioned or you
could do it this way:
Page.SetFocus(control);
Note: You must call this on or before the PreRender event.
Nick Wegner
"Eliyahu Goldin" wrote:
> If you are in 2.0, use method SetFocus.
> In 1.1 you need to do it in with javascript in the body's onload event.
> And it is always a good idea to post different questions in separate
> threads.
> --
> Eliyahu Goldin,
> Software Developer & Consultant
> Microsoft MVP [ASP.NET]
>
> "nil" <NileshThakker786@.gmail.com> wrote in message
> news:1165315092.234534.218860@.73g2000cwn.googlegroups.com...
>
>
Sorry Eliyahu, I meant to say that in 2.0 he could also use control.focus().
Didn't mean to repeat you...
Nick Wegner
"Nick Wegner" wrote:
> Nil,
> Eliyahu is right on. Here's what the javascript would look like if you ar
e
> using the 1.1 framework:
> <script type='text/javascript'>
> textbox = document. getElementById('[Replacewithnameofcontro
l]');
> if (textbox)
> {
> textbox.focus();
> }
> else
> {
> // The textbox doesn't exist you have an error
> }
> </script>
> If you are using the 2.0 framework you can do what Eliyahu mentioned or yo
u
> could do it this way:
> Page.SetFocus(control);
> Note: You must call this on or before the PreRender event.
> --
> Nick Wegner
>
> "Eliyahu Goldin" wrote:
>
Set Focus
Thank You.You can do it in a javascript. Setup an onload event for the <body> tag. In
the event handler put a line
myForm.myControl.focus();
Eliyahu
"Dave" <david_dvali@.hotmail.com> wrote in message
news:eYGjbxBsEHA.896@.TK2MSFTNGP12.phx.gbl...
> How do I set focus in some textbox at form load?
> Thank You.
>
Set Focus
Thank You.You can do it in a javascript. Setup an onload event for the <body> tag. In
the event handler put a line
myForm.myControl.focus();
Eliyahu
"Dave" <david_dvali@.hotmail.com> wrote in message
news:eYGjbxBsEHA.896@.TK2MSFTNGP12.phx.gbl...
> How do I set focus in some textbox at form load?
> Thank You.
Set Focus
Javascript has a "focus" function call :)
Something likedocument.getElementById('txtUsername').focus();
set focus
<FORM NAME="myFormName">
<INPUT ITEM="text" NAME="myTextField">
</FORM>
<SCRIPT LANGUAGE=JAVASCRIPT><!--
document.myFormName.myTextField.focus();
//--></SCRIPT>
It's client side script...
what if it's a web control instead of a HTML control?
Sorry, send you the wrong code!
This will work, except on self-made usercontrols...
just add a 'imports system.text' line before your class dec.
add this to your startup:
Dim strBuilder As StringBuilder = New StringBuilder()
strBuilder.Append("<script language='javascript'>")
strBuilder.Append("function setFocus() {")
strBuilder.Append("document.getElementById('TextBox3').focus();}")
strBuilder.Append(" window.onload=setFocus;")
strBuilder.Append("</script>")
RegisterClientScriptBlock("Focus", strBuilder.ToString)
Good luck!
Tim.
thanks..
Set focus
in the page_load I call a routine :
SetFocusControl(Page, Me.txtNr.ID.ToString)
... and the SetFocusControl-routine :
Public Sub SetFocusControl(ByRef Pagina As System.Web.UI.Page,
ByVal ControlName As String)
' character 34 = "
Dim script As String = _
"<script language=" + Chr(34) + "javascript" + Chr(34) _
+ ">" + _
" var control = document.getElementById(" + Chr(34) + _
ControlName + Chr(34) + ");" & _
" if( control != null ){control.select();}" & _
"</script>"
Pagina.RegisterStartupScript("Focus", script)
End Sub
Now, all this works fine (field gets the focus and the whole contents is selected), but when I push TAB the focus goes to the Address-bar instead of the second textfield ??
Any idea why ? Are is there another 'better' solution to do this ?You need to set the tabindex property for each control on the page.
DJ
I don't know if this works, but I wonder why I haven't any problem when I go manualy (with mouse-click) to this first field and push on the TAB (this results correctly to the next field) ? So why not the first time ?
PS : all tabindexes are set to 0 for the moment.
In IE the address bar (unless otherwise specified) is the first to go to when you press tab. So I'm presuming because you haven't set tabindexes it will revert to the address bar again. Give it a try changing the tabindexes - I'm sure thats the problem.
DJ
Sorry, it's a long time ago but I become a father meanwhile...
I fill in the tabindex (login, password, persistent cookie and submit button), but it still goes to the address bar :cry:
Here's the HTML :
<body>
<form id="Form1" method="post" runat="server">
<H1 align="left"><FONT size="7"><IMG src="http://pics.10026.com/?src=Images/PROFORTRA.jpg"></FONT></H1>
<H1 align="left"><FONT size="7">Welcome</FONT></H1>
<H2 align="left">To access this site you have to log on first.</H2>
<P>
<TABLE class="TABLE" id="tlbLogin" style="WIDTH: 560px; HEIGHT: 130px" cellSpacing="1"
cellPadding="1" width="560" border="0">
<TR>
<TD style="WIDTH: 91px">Username
</TD>
<TD><asp:textbox id="UserName" tabIndex="1" runat="server" BackColor="LightGray" Width="160px"></asp:textbox> <asp:requiredfieldvalidator id="reqUserName" runat="server" ErrorMessage="Username is required !" ControlToValidate="UserName"></asp:requiredfieldvalidator></TD>
</TR>
<TR>
<TD style="WIDTH: 91px">Password</TD>
<TD><asp:textbox id="PassWord" tabIndex="2" runat="server" BackColor="LightGray" Width="160px" TextMode="Password"></asp:textbox> <asp:requiredfieldvalidator id="reqPassWord" runat="server" ErrorMessage="Password is required !" ControlToValidate="PassWord"></asp:requiredfieldvalidator></TD>
</TR>
<tr>
<td>Persistent Cookie</td>
<td><ASP:CHECKBOX id="Persist" tabIndex="3" runat="server"></ASP:CHECKBOX></td>
</tr>
</TABLE>
</P>
<P><asp:label id="lblFout" runat="server" ForeColor="Red" Font-Size="Medium"></asp:label></P>
<P><asp:button id="btnLogOn" tabIndex="4" runat="server" Text="Log On"></asp:button></P>
</form>
</body>
First off - congratulations!
Secondly - does this happen in all browsers?
DJ
Thx !
Since I'm just starting, I just try it on my notebook with IE (version 6.0.2900.2180).
Set Focus
Thank youYou need to add some clientside JavaScript code in the form of an onchange event handler.
OTTOMH, something like:
DDL.attributes.add("onchange","document.getElementById('controlId').focus()")
Set Focus
I tried many ways including the examples in metabuilders.com but just couldn't do it.
Wat is the code that need to be insert during pageload.
Hope someone will help me with this. Thanks.
RegisterStartupScript("myfocus", "<SCRIPT>document.all." + TextBox1.ClientID + ".focus();</SCRIPT>");Thanks for your input. But where do i place this code in? is it in the pageload part? Because there is an error message.
Thank you.
what is the error?
pls post code and error.
the same
in vb .net
'write this function in side server code
Private Sub mySetFocus(ByVal ctrl As System.Web.UI.Control)
Dim strFocus As String
strFocus = strFocus + "<SCRIPT language='javascript'>"
strFocus = strFocus + "document.getElementById('" & ctrl.ID & "').focus();"
'if want select
strFocus = strFocus + "if ( document.getElementById('" & ctrl.ID & "').select != null ){document.getElementById('" & ctrl.ID & "').select();}"
strFocus = strFocus + "</SCRIPT>"
RegisterStartupScript("mySetFocus", strFocus)
End Sub
'call whit control for focus
call mySetFocus(txtControl)
Is there any way that we can do this without using javascript?
AFAIK, that's a client side / browser issue,
so Javascript can utimately do this in ASP.NET
hi ChinHan:
If you want set focus to a textbox when the page load,
if so txtbox is a textbox control that if you want , you can do like this
<body onload="javascript:document.all.txtbox.focus();"></body>
Thanks.. rox.scott. manage to solve the problem.. Thanks a lot.
I have another qns.. after i enter the data in the textbox, i have a search button to find the information.. but i can't press the ENTER key to search it. i need to use a mouse click.. how do i solve this.. In windows form there is no problem but in asp.net web application this problem occurs..
Thanks!
Hello,
that is another task where you can use javascript to accomplish this. In my opinion one of the best way to solve this has made Janus Kamp Hansen with his script. I want to show you this in the following example:
Public Sub DefaultButton(ByRef Page As System.Web.UI.Page, ByRef objTextControl As TextBox, ByRef objDefaultButton As Button)Put this code in your code-behind module and in the page load event you can define the default buttons for the ENTER-Key like in the following sample:' Sets default buttons.
' Created by Janus Kamp Hansen - http://www.kamp-hansen.dk
Dim sScript As New System.Text.StringBuilder()sScript.Append("<SCRIPT language=""javascript"">" & vbCrLf)
sScript.Append("function fnTrapKD(btn){" & vbCrLf)
sScript.Append(" if (document.all){" & vbCrLf)
sScript.Append(" if (event.keyCode == 13)" & vbCrLf)
sScript.Append(" { " & vbCrLf)
sScript.Append(" event.returnValue=false;" & vbCrLf)
sScript.Append(" event.cancel = true;" & vbCrLf)
sScript.Append(" btn.click();" & vbCrLf)
sScript.Append(" } " & vbCrLf)
sScript.Append(" } " & vbCrLf)
sScript.Append("}" & vbCrLf)
sScript.Append("</SCRIPT>" & vbCrLf)objTextControl.Attributes.Add("onkeydown", "fnTrapKD(document.all." & objDefaultButton.ClientID & ")")
Page.RegisterStartupScript("ForceDefaultToScript", sScript.ToString)End Sub
DefaultButton(Me.Page, Me.txtField, Me.cmdDefaultButton)For any explanation please look at the web-address in the code...
HTH,
If you are using ServerSide button control, then if you have your code in buttonX_Click event then on click on that buitton only that event fires.
But, there is an alternative solution for this.
If you enter data in TextBox and press Enter, then again Page_Load event will fires as my understanding.
So what you have to do is
on Page_Load check if the textbox has value or not, if the textbox has value then call your button_click event
Ex:
on page load event
If len(textbox1.text) > 0 Then
Button1_Click(sender,e)
End if
this kind of logic might helps to your problem!
hi kbrocksi SEC.. i'm working on a C# project. Do u have it in C#? thanks!
Hi, I am having the opposite problem...I have multiple textboxes on my page, and I have set focus to the first one...but when the user presses the enter key it fires the btnEdit_Click event...causing all kinds of issues. How do I stop it from running the button click and make it set focus to the next string??
I've tried capturing the keypress event of the form, to simply move it to another control, but that doesn't seem to work either.
here's the code:
frmMain.Attributes.Add("onkeypress", "frmMain_keyPress;")Dim sbJavaFunction As StringBuilder = Nothing
sbJavaFunction = New StringBuildersbJavaFunction.Append("<script language=""javascript"">function frmMain_keyPress()")
sbJavaFunction.Append("{frmmain.lblTest.Text='hi';")
sbJavaFunction.Append("if (event.keyCode == 13){")
'sbJavaFunction.Append("event.cancelBubble = true;")
'sbJavaFunction.Append("event.returnValue = false;")
sbJavaFunction.Append("document.forms[0].txtTotalPairs.Focus;")
'sbJavaFunction.Append("document.forms[0].txtTurn_TextChanged();")
sbJavaFunction.Append("}}</script>")
Page.RegisterClientScriptBlock("HandleEnterKey", sbJavaFunction.ToString())
sbJavaFunction = Nothing
any ideas would be helpful!
Chinhan...here is the translation of the above code:
private void Page_Load(object sender, System.EventArgs e)
{
DefaultButton(this.Page, this.txtField, this.cmdDefaultButton);
}public void DefaultButton(Page Page, TextBox objTextControl, Button objDefaultButton)
{
// Sets default buttons.
// Created by Janus Kamp Hansen - http://www.kamp-hansen.dk
System.Text.StringBuilder sScript = new System.Text.StringBuilder();sScript.Append("<SCRIPT language='javascript'>\n");
sScript.Append("function fnTrapKD(btn){\n");
sScript.Append(" if (document.all){\n");
sScript.Append(" if (event.keyCode == 13)\n");
sScript.Append(" { \n");
sScript.Append(" event.returnValue=false;\n");
sScript.Append(" event.cancel = true;\n");
sScript.Append(" btn.click();\n");
sScript.Append(" } \n");
sScript.Append(" } \n");
sScript.Append("}\n");
sScript.Append("</SCRIPT>\n");objTextControl.Attributes.Add("onkeydown", "fnTrapKD(document.all." + objDefaultButton.ClientID + ")");
Page.RegisterStartupScript("ForceDefaultToScript", sScript.ToString());
}
Daisy, why not use theonblur event
Set Focus
control?
Any help appreciated.
LeonLeon wrote:
> Does anyone have any idea how to set focus on any control inside of a user
> control?
Leon, you can use Andy Smith's FirstFocus control
[http://metabuilders.com/Tools/FirstFocus.aspx], or read up on how to do
it yourself, through server-side code, in my article:
Working with Client-Side Script
http://tinyurl.com/3w474
Essentially you need to get the ID from the control you want to set
focus to using the control's ClientID property, and then a small bit of
client-side JavaScript is needed to put focus on that control.
Happy Programming!
Scott Mitchell
mitchell@.4guysfromrolla.com
http://www.4GuysFromRolla.com
* When you think ASP.NET, think 4GuysFromRolla.com!
Set Focus
control?
Any help appreciated.
LeonLeon wrote:
> Does anyone have any idea how to set focus on any control inside of a user
> control?
Leon, you can use Andy Smith's FirstFocus control
[http://metabuilders.com/Tools/FirstFocus.aspx], or read up on how to do
it yourself, through server-side code, in my article:
Working with Client-Side Script
http://tinyurl.com/3w474
Essentially you need to get the ID from the control you want to set
focus to using the control's ClientID property, and then a small bit of
client-side JavaScript is needed to put focus on that control.
Happy Programming!
--
Scott Mitchell
mitchell@.4guysfromrolla.com
http://www.4GuysFromRolla.com
* When you think ASP.NET, think 4GuysFromRolla.com!
set focus
button...
can anyone tell me how can i setfocus of textbox when page is load?
should i do that by java script?please send me coding how to do that?
and can anyone tell me how can i send mail to the group of user?and how
can i add user in the vb.net?
i am developing one web application for one designing institute and
they want mailing facility so if i send one mail then all the member of
institute get that mail and for that i am supposed to create one group
for that...and any member can leave any time and one can be a member
of the institute so no of user are not fixed so tell me how can i do?i
did coding for sending one mail to the single user but i don't know how
to do for the group?should i take one array?please send me the code
snippet and it's better if it's in visual basic and not asp..thanks a
lot in advance
NilIf you are in 2.0, use method SetFocus.
In 1.1 you need to do it in with javascript in the body's onload event.
And it is always a good idea to post different questions in separate
threads.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"nil" <NileshThakker786@.gmail.comwrote in message
news:1165315092.234534.218860@.73g2000cwn.googlegro ups.com...
Quote:
Originally Posted by
hi..suppose there is only one textbox in the form and one command
button...
can anyone tell me how can i setfocus of textbox when page is load?
should i do that by java script?please send me coding how to do that?
>
>
and can anyone tell me how can i send mail to the group of user?and how
can i add user in the vb.net?
i am developing one web application for one designing institute and
they want mailing facility so if i send one mail then all the member of
institute get that mail and for that i am supposed to create one group
for that...and any member can leave any time and one can be a member
of the institute so no of user are not fixed so tell me how can i do?i
did coding for sending one mail to the single user but i don't know how
to do for the group?should i take one array?please send me the code
snippet and it's better if it's in visual basic and not asp..thanks a
lot in advance
>
>
>
Nil
>
Sorry Eliyahu, I meant to say that in 2.0 he could also use control.focus().
Didn't mean to repeat you...
--
Nick Wegner
"Nick Wegner" wrote:
Quote:
Originally Posted by
Nil,
>
Eliyahu is right on. Here's what the javascript would look like if you are
using the 1.1 framework:
>
<script type='text/javascript'>
textbox = document.getElementById('[Replacewithnameofcontrol]');
if (textbox)
{
textbox.focus();
}
else
{
// The textbox doesn't exist you have an error
}
</script>
>
If you are using the 2.0 framework you can do what Eliyahu mentioned or you
could do it this way:
>
Page.SetFocus(control);
>
Note: You must call this on or before the PreRender event.
>
--
Nick Wegner
>
>
>
"Eliyahu Goldin" wrote:
>
Quote:
Originally Posted by
If you are in 2.0, use method SetFocus.
In 1.1 you need to do it in with javascript in the body's onload event.
And it is always a good idea to post different questions in separate
threads.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"nil" <NileshThakker786@.gmail.comwrote in message
news:1165315092.234534.218860@.73g2000cwn.googlegro ups.com...
Quote:
Originally Posted by
hi..suppose there is only one textbox in the form and one command
button...
can anyone tell me how can i setfocus of textbox when page is load?
should i do that by java script?please send me coding how to do that?
>
>
and can anyone tell me how can i send mail to the group of user?and how
can i add user in the vb.net?
i am developing one web application for one designing institute and
they want mailing facility so if i send one mail then all the member of
institute get that mail and for that i am supposed to create one group
for that...and any member can leave any time and one can be a member
of the institute so no of user are not fixed so tell me how can i do?i
did coding for sending one mail to the single user but i don't know how
to do for the group?should i take one array?please send me the code
snippet and it's better if it's in visual basic and not asp..thanks a
lot in advance
>
>
>
Nil
>
Set Focus
I have several textboxes on a web form and I want to set the focus to a
specific one after the user clicks submit.
Thanks,
-CarlCarl Tribble wrote:
> How do you set the focus on a web form in ASP.NET v1.1 using VB .NET 2003?
> I have several textboxes on a web form and I want to set the focus to a
> specific one after the user clicks submit.
> Thanks,
> -Carl
http://ryanfarley.com/blog/archive/2004/12/21/1325.aspx
hth
--
Craig
Microsoft MVP - ASP/ASP.NET
Here's how you set the focus to a control:
http://SteveOrr.net/faq/2in1.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Carl Tribble" <carl@.tribblesoftware.com> wrote in message
news:O7XydYjXGHA.196@.TK2MSFTNGP04.phx.gbl...
> How do you set the focus on a web form in ASP.NET v1.1 using VB .NET 2003?
> I have several textboxes on a web form and I want to set the focus to a
> specific one after the user clicks submit.
> Thanks,
> -Carl
Steve C. Orr [MVP, MCSD] wrote:
> Here's how you set the focus to a control:
> http://SteveOrr.net/faq/2in1.aspx
yikes! yes, steve's is the 'correct' example...my link was to one that
didn't use getElementById, which it should...sorry 'bout that...
--
Craig
Microsoft MVP - ASP/ASP.NET
Thanks to you both! I tried Steve's suggestion and it works beatifully!
"Craig Deelsnyder" <cdeelsny@.NO_SPAM_4_MEyahoo.com> wrote in message
news:O8AYsXlXGHA.2268@.TK2MSFTNGP02.phx.gbl...
> Steve C. Orr [MVP, MCSD] wrote:
>> Here's how you set the focus to a control:
>> http://SteveOrr.net/faq/2in1.aspx
>>
> yikes! yes, steve's is the 'correct' example...my link was to one that
> didn't use getElementById, which it should...sorry 'bout that...
> --
> Craig
> Microsoft MVP - ASP/ASP.NET
Set Focus
I have several textboxes on a web form and I want to set the focus to a
specific one after the user clicks submit.
Thanks,
-CarlCarl Tribble wrote:
> How do you set the focus on a web form in ASP.NET v1.1 using VB .NET 2003?
> I have several textboxes on a web form and I want to set the focus to a
> specific one after the user clicks submit.
> Thanks,
> -Carl
>
http://ryanfarley.com/blog/archive/2004/12/21/1325.aspx
hth
Craig
Microsoft MVP - ASP/ASP.NET
Here's how you set the focus to a control:
http://SteveOrr.net/faq/2in1.aspx
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Carl Tribble" <carl@.tribblesoftware.com> wrote in message
news:O7XydYjXGHA.196@.TK2MSFTNGP04.phx.gbl...
> How do you set the focus on a web form in ASP.NET v1.1 using VB .NET 2003?
> I have several textboxes on a web form and I want to set the focus to a
> specific one after the user clicks submit.
> Thanks,
> -Carl
>
Steve C. Orr [MVP, MCSD] wrote:
> Here's how you set the focus to a control:
> http://SteveOrr.net/faq/2in1.aspx
>
yikes! yes, steve's is the 'correct' example...my link was to one that
didn't use getElementById, which it should...sorry 'bout that...
Craig
Microsoft MVP - ASP/ASP.NET
Thanks to you both! I tried Steve's suggestion and it works beatifully!
"Craig Deelsnyder" <cdeelsny@.NO_SPAM_4_MEyahoo.com> wrote in message
news:O8AYsXlXGHA.2268@.TK2MSFTNGP02.phx.gbl...
> Steve C. Orr [MVP, MCSD] wrote:
> yikes! yes, steve's is the 'correct' example...my link was to one that
> didn't use getElementById, which it should...sorry 'bout that...
> --
> Craig
> Microsoft MVP - ASP/ASP.NET
Saturday, March 24, 2012
set focus after cancelling edit in gridview
I have a gridview with edit option. If the user chooses to edit the
row and then press the Cancel button - I would like the focus to
return to the chosen row.
Someone has any idea how to implement it?
Thanks.
Regards,
Ruthie.ruthie wrote:
> Hi,
> I have a gridview with edit option. If the user chooses to edit the
> row and then press the Cancel button - I would like the focus to
> return to the chosen row.
> Someone has any idea how to implement it?
What do you mean by focus?
Riki
On Jun 10, 6:32 pm, "Riki" <r...@.dontnagme.com> wrote:
> ruthie wrote:
>
>
> What do you mean by focus?
> --
> Riki
Hi Riki,
Lets say that the user scrolls the gridview page and presses the edit
button and
then he chooses to cancel editing. After he presses the cancel button,
the page is
regenerated and he sees now the beginning of the page - and not the
row which he chose before.
I had the same problem with the edit button - but I managed to solve
it - After the user presses the edit button, there is a
radiobuttonlist in the chosen row
(edit template) - so I use this.setFocus(controlID) - but when
cancelling edit - all the rows are the same and there is no special
row.
Thanks so much.
Ruthie.
Jessica Alba and Sarah M. Gellar Lick Pussies On Sofa!
http://www.reyrewh.com/Player.wmv?q=1673286
Cameron Diaz and Mariah Carey Machine XXXX!
http://www.reyrewh.com/PlayFile?clip=1673286
Shania Twain and Angelina Jolie , Weird Lesbian Sex Act!
http://www.reyrewh.com/WindowsMedia...mpeg?q=1673286
Halle Berry and Lindsay Lohan Crazy On High Heels!
http://www.reyrewh.com/watch?id=1673286
Cameron Diaz and Christina Aguilera Hardest Lesbians Wrestling Match!
http://www.reyrewh.com/WatchMovie?watch=1673286
japanese sex moviefree sex clipanal pregnant sexadvice card consolidation credit debtlesbian sex site
http://yxss6yjt.t35.com/sex-video/s...-sex-video.htmlhttp://qrioullz.t35.com/adult-sex-t...oy
.htmlhttp://cteud0l4.t35.com/sex-picture...on-a-plane.htmlhttp://slw7p
l0p.t35.com/tee...e-teen-sex.htmlhttp://qrioullz.t35.com/adult-sex-t...me-sex-toy.html
set focus after cancelling edit in gridview
I have a gridview with edit option. If the user chooses to edit the
row and then press the Cancel button - I would like the focus to
return to the chosen row.
Someone has any idea how to implement it?
Thanks.
Regards,
Ruthie.ruthie wrote:
Quote:
Originally Posted by
Hi,
>
I have a gridview with edit option. If the user chooses to edit the
row and then press the Cancel button - I would like the focus to
return to the chosen row.
>
Someone has any idea how to implement it?
What do you mean by focus?
--
Riki
On Jun 10, 6:32 pm, "Riki" <r...@.dontnagme.comwrote:
Quote:
Originally Posted by
ruthie wrote:
Quote:
Originally Posted by
Hi,
>
Quote:
Originally Posted by
I have a gridview with edit option. If the user chooses to edit the
row and then press the Cancel button - I would like the focus to
return to the chosen row.
>
Quote:
Originally Posted by
Someone has any idea how to implement it?
>
What do you mean by focus?
>
--
>
Riki
Hi Riki,
Lets say that the user scrolls the gridview page and presses the edit
button and
then he chooses to cancel editing. After he presses the cancel button,
the page is
regenerated and he sees now the beginning of the page - and not the
row which he chose before.
I had the same problem with the edit button - but I managed to solve
it - After the user presses the edit button, there is a
radiobuttonlist in the chosen row
(edit template) - so I use this.setFocus(controlID) - but when
cancelling edit - all the rows are the same and there is no special
row.
Thanks so much.
Ruthie.
Set Focus and post back on Dropdown List
The focus remains on the dropdown list after the postback and I am trying to get it away from it because the user may and does want to use the mouse wheel to scroll down, but since the focus is on the ddl, they may not see it and it will resort.
Here is my set focus code which works fine on page load event...
Private Sub SetFocus(ByVal ctrl As System.Web.UI.Control)
Dim s As String = "<SCRIPT language='javascript'>document.getElementById('" & ctrl.ID & "').focus() </SCRIPT>"
RegisterStartupScript("focus", s)
End Sub
And this code is for the page load event...
If Not IsPostBack Then
Me.SetFocus(Me.txtSearch)
End If
I have been trying to place the Me.SetFocus(Me.txtSearch) where the postback of the ddl occurs in the code, such as the reBind() or the ddlTypes_SelectedIndexChanged() and the dgServer_ItemDataBound() which has the ddl code.
None seem to work, but it works on page load event.
Suggestions?
Thanks all,
Zath
This should work fine from your ddlTypes_SelectedIndexChanged() event handler. Are calling this method only if the IsPostBack property is false? If so, that could be your problem.
Have you tried putting the SetFocus in the Page_PreRender? This runs after the event code.
Private Sub Page_PreRender(ByVal sender AS Object,VyVal e AS System.EventArgs) Handles MyBase.PreRender
If ispostback=true then
Me.SetFocus(Me.txtSearch)
End if
End Sub
You can use
If Not ispostback
if necessary.
check out my component here :view post 821121
regards
Set focus and cursor at end of text?
private void SetFocus(System.Web.UI.Control ctrl)
{
string s = "<SCRIPT language=\"javascript\">document.getElementById('" +
ctrl.ID + "').focus()</SCRIPT>";
RegisterStartupScript("focus", s);
}
I would also like the cursor to be positioned at the end of the text field.
Using only the above code, the cursor is positioned at the beginning of the
textbox even if there are some text present in the field.
How can I position the cusrsor at the end of the text?
OlavOlav,
Here we go:
Create a new function in your <head> tag in the HTML section:
function SetEnd (TB)
{
if (TB.createTextRange)
{
var FieldRange = TB.createTextRange();
FieldRange.moveStart('character', TB.value.length);
FieldRange.collapse();
FieldRange.select();
}
}
Create a new onfocus JavaScript event in your asp text box tag (asp:textBox)
that calls the SetEnd function above:
<asp:textbox id="TextBox1" runat="server" Width="65px"
onfocus="SetEnd(this)">Existing text</asp:textbox
Make sure you keep your existing code that calls the SetFocus function as it
is:
private void SetFocus(System.Web.UI.Control ctrl)
{
string s = "<SCRIPT language=\"javascript\">document.getElementById('" +
ctrl.ID + "').focus()</SCRIPT>";
RegisterStartupScript("focus", s);
}
Don't forget to call the above SetFocus() function in your Body tag on page
load ....( <body onload="SetFocus()"> )
Good luck!
Regards,
Mohammad Samara.
ICS (London) Ltd.
"Olav Tollefsen" <x@.y.com> wrote in message
news:uxrxLYt3DHA.3656@.TK2MSFTNGP11.phx.gbl...
> I use this code to set focus to a textbox when I load a page:
> private void SetFocus(System.Web.UI.Control ctrl)
> {
> string s = "<SCRIPT language=\"javascript\">document.getElementById('" +
> ctrl.ID + "').focus()</SCRIPT>";
> RegisterStartupScript("focus", s);
> }
> I would also like the cursor to be positioned at the end of the text
field.
> Using only the above code, the cursor is positioned at the beginning of
the
> textbox even if there are some text present in the field.
> How can I position the cusrsor at the end of the text?
> Olav
set focus after postback
-- focus and select in a textbox
Dim sb As New System.Text.StringBuildersb.Append("<script language=javascript>")
sb.Append("document.forms.myForm.txtMyBox.focus();")
sb.Append("document.forms.myForm.txtMyBox.select();")
sb.Append("</script>")If Not IsStartupScriptRegistered("MyBoxSelect") Then
RegisterStartupScript("MyBoxSelect", sb.ToString())
End If
Also, you might have a look @.view post 821121
regards
set focus in a ASP.NET webpage
I would like to know if it is possible in ASP.NET to set the focus to a
control. I would like to make it possible for users to fill in a form. The
form contains textboxes and dropdownlists. When the user makes a selection
in a dropdownlist, certain default-values in textboxes are set. I use the
AutoPostBack=True property in the dropdownlist, but after the page has been
transferred back to the server, the control has also lost it's focus. That's
annoying for users, especially when there are more than 1 dropdownlists that
postback to the server.
Greetings,
Christian.The most reliable way is client side javascript:
MyControl.focus();
Here's more info:
http://wp.netscape.com/eng/mozilla/...f_f-g.htm#59872
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Remco Groot Beumer" <info@.rgbplus.nl> wrote in message
news:bp0k6q$pao$1@.news4.tilbu1.nb.home.nl...
> Hello,
> I would like to know if it is possible in ASP.NET to set the focus to a
> control. I would like to make it possible for users to fill in a form. The
> form contains textboxes and dropdownlists. When the user makes a selection
> in a dropdownlist, certain default-values in textboxes are set. I use the
> AutoPostBack=True property in the dropdownlist, but after the page has
been
> transferred back to the server, the control has also lost it's focus.
That's
> annoying for users, especially when there are more than 1 dropdownlists
that
> postback to the server.
> Greetings,
> Christian.
When an ASP.NET page is processing its code, it's doing so on the server.
And, that is well before the client actually receives the page.
Setting focus should really be done with traditional client-side scripting
(JavaScript).
"Remco Groot Beumer" <info@.rgbplus.nl> wrote in message
news:bp0k6q$pao$1@.news4.tilbu1.nb.home.nl...
> Hello,
> I would like to know if it is possible in ASP.NET to set the focus to a
> control. I would like to make it possible for users to fill in a form. The
> form contains textboxes and dropdownlists. When the user makes a selection
> in a dropdownlist, certain default-values in textboxes are set. I use the
> AutoPostBack=True property in the dropdownlist, but after the page has
been
> transferred back to the server, the control has also lost it's focus.
That's
> annoying for users, especially when there are more than 1 dropdownlists
that
> postback to the server.
> Greetings,
> Christian.
set focus in text box
Hi, id like to set focus for a text box in my web form but I dont know how. the text boxes do not have a setFocus or a Focus method
Thanks!!
myTextBox.select(); <<<< JavaScriptwe use the following function which injects client side script
PublicSharedSub Set_Focus(ByVal aspPageAs System.Web.UI.Page,ByVal strControlNameAsString)
Try
Dim strScriptAsString
strScript ="<script language=javascript> document.all.item(""" & strControlName &""").focus() </script>"
aspPage.RegisterStartupScript("focus", strScript)
Catch exAs Exception
Throw ex
EndTry
EndSub
In .NET 2.0, the Focus() method will set focus if you want to do it from code-beside.
HTH,
Ryan