Click here to Skip to main content
15,918,485 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: where do I find DefaultClientScript property Pin
Michael Sync3-Jul-07 17:06
Michael Sync3-Jul-07 17:06 
GeneralRe: where do I find DefaultClientScript property Pin
GuildfordG3-Jul-07 22:32
GuildfordG3-Jul-07 22:32 
GeneralRe: where do I find DefaultClientScript property Pin
Michael Sync3-Jul-07 23:03
Michael Sync3-Jul-07 23:03 
GeneralRe: where do I find DefaultClientScript property Pin
GuildfordG4-Jul-07 15:06
GuildfordG4-Jul-07 15:06 
QuestionSetting Button and Textbox focus Pin
devil853-Jul-07 10:53
devil853-Jul-07 10:53 
AnswerRe: Setting Button and Textbox focus Pin
RepliCrux3-Jul-07 13:32
RepliCrux3-Jul-07 13:32 
AnswerRe: Setting Button and Textbox focus Pin
sidbaruah3-Jul-07 18:56
sidbaruah3-Jul-07 18:56 
AnswerRe: Setting Button and Textbox focus Pin
Fred_Smith4-Jul-07 10:50
Fred_Smith4-Jul-07 10:50 
Actually, there are ways.... (there is always a way...)

This is how I solved it - my page has two textboxes, one for login and one for search, and two submit buttone - one for each - but like you I wanted the user to to be able to hit ENTER and have the "right" submit made...

This method is not foolproof, but works well enough and on all PC platforms I've tried and some but not all Mac OS's... (but that's Macs for you...)

Tweak it suit, obviously, but this is it cut down it's bones:

OK... login and search, and their buttons:

Member login:
<asp:TextBox id="txtLogin" runat="server" />
Password:
<asp:TextBox id="txtPwd" runat="server" TextMode="Password" />
<asp:LinkButton runat="server" ID="lbGo" OnClick="SubmitLogin" Text="Go"></asp:LinkButton>

Search:
<asp:TextBox id="txtSiteSearch" runat="server" ></asp:TextBox>
<asp:LinkButton runat="server" ID="lbSearch" OnClick="SiteSearch" Text="Go"></asp:LinkButton>


and some Javascript for the head of your page:


<script language="javascript">
function login13(e) {
if (e.keyCode==13) { __doPostBack('lfLogin$lbGo',''); }
}
function search13(e) {
if (e.keyCode==13) { __doPostBack('lfLogin$lbSearch',''); }
}
</script>


and in your code-behind:

Private Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
txtPwd.Attributes.Add("onkeyup", "return login13(event)")
txtSiteSearch.Attributes.Add("onkeyup", "return search13(event)")
End If
End Sub


Clearly you'll need to change both the javascript adn the code-behind to suit your controls' ID's... if you're not sure about the javascript __doPostBack arguments (NB the double-underscore) then run your page and look at the source as rendered in your browser and take the names from there...

Good luck....

Fred

GeneralRe: Setting Button and Textbox focus Pin
devil855-Jul-07 4:39
devil855-Jul-07 4:39 
QuestionWhich button was clicked within a form. Pin
Martin_3-Jul-07 10:48
Martin_3-Jul-07 10:48 
AnswerRe: Which button was clicked within a form. Pin
Christian Graus3-Jul-07 10:56
protectorChristian Graus3-Jul-07 10:56 
GeneralRe: Which button was clicked within a form. Pin
Martin_5-Jul-07 3:46
Martin_5-Jul-07 3:46 
QuestionReportViewer vertical Scrollbar crash Pin
BGadhia3-Jul-07 10:15
BGadhia3-Jul-07 10:15 
AnswerRe: ReportViewer vertical Scrollbar crash Pin
BGadhia3-Jul-07 12:51
BGadhia3-Jul-07 12:51 
QuestionASP YouTube Clone Script Pin
septemberq3-Jul-07 9:23
septemberq3-Jul-07 9:23 
QuestionCreate a .csv file from an odbc connection Pin
markymark823-Jul-07 8:24
markymark823-Jul-07 8:24 
QuestionCan any body tell me any sites or downloads for taking suppor Pin
indian1433-Jul-07 7:15
indian1433-Jul-07 7:15 
AnswerRe: Can any body tell me any sites or downloads for taking suppor Pin
leckey3-Jul-07 8:03
leckey3-Jul-07 8:03 
GeneralRe: Can any body tell me any sites or downloads for taking suppor Pin
indian1433-Jul-07 18:05
indian1433-Jul-07 18:05 
GeneralRe: Can any body tell me any sites or downloads for taking suppor Pin
Sathesh Sakthivel3-Jul-07 18:18
Sathesh Sakthivel3-Jul-07 18:18 
GeneralRe: Can any body tell me any sites or downloads for taking suppor Pin
indian1434-Jul-07 2:53
indian1434-Jul-07 2:53 
QuestionRating System? Pin
Bacanze3-Jul-07 6:31
Bacanze3-Jul-07 6:31 
Questionhow to add a new row in a grid at runtime Pin
jamesmani2k53-Jul-07 4:24
jamesmani2k53-Jul-07 4:24 
AnswerRe: how to add a new row in a grid at runtime Pin
ToddHileHoffer3-Jul-07 7:26
ToddHileHoffer3-Jul-07 7:26 
GeneralRe: how to add a new row in a grid at runtime Pin
jamesmani2k53-Jul-07 19:13
jamesmani2k53-Jul-07 19:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.