.NETGURU
how to implement an onclick on asp:TextBox?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.aspnet.

Post a new message to this list...

Jan Hoffman
hi @all

I have the following element in an ascx-file:

<asp:TextBox id="name" runat="server">name</asp:TextBox>

The textbox belongs to an application of a telefonebook.
I want that if I click into the Textbox *once* that the text "name" is
selceted. at the moment I have to double-click.

any solutions to this problem?
thanks
Jan

Reply to this message...
 
    
Eliyahu Goldin
Jan,

It can be done in javascript on client side usind onclick event.

Eliyahu

"Jan Hoffman" <Click here to reveal e-mail address> wrote in message
news:el$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Shiva
Try this:
<asp:TextBox RunAt=Server Id="name" onClick="this.select();" />

"Jan Hoffman" <Click here to reveal e-mail address> wrote in message
news:el$Click here to reveal e-mail address...
hi @all

I have the following element in an ascx-file:

<asp:TextBox id="name" runat="server">name</asp:TextBox>

The textbox belongs to an application of a telefonebook.
I want that if I click into the Textbox *once* that the text "name" is
selceted. at the moment I have to double-click.

any solutions to this problem?
thanks
Jan

Reply to this message...
 
    
Jan Hoffman
hi Shiva,

thank you....it works
but visual studio 2003 does not recognize the onclick parameter in the HTML
view! that's why I thought it would not work :(

Jan

"Shiva" <Click here to reveal e-mail address> schrieb im Newsbeitrag
news:ON%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Eliyahu Goldin
Jan,

It already had been discussed once. OnClick is not documented for server
controls. Use it if you are happy with using undocumented features.
Otherwise use Attributes["onclick"] in code-behind.

Eliyahu

"Jan Hoffman" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jan Hoffman
how can I impelent it with code behind?
Jan

"Eliyahu Goldin" <Click here to reveal e-mail address> schrieb im Newsbeitrag
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Shiva
Hi,
You use the Attributes collection: Text1.Attributes.Add ("onClick",
"this.select();"); // C#

"Jan Hoffman" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
how can I impelent it with code behind?
Jan

"Eliyahu Goldin" <Click here to reveal e-mail address> schrieb im Newsbeitrag
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Eliyahu Goldin
One way is to put a line (c# syntax)

name.Attributes["onclick"]="this.select();"

in the page's PreRender event handler.

Eliyahu

"Jan Hoffman" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Web.UI.MobileControls.TextBox
System.Web.UI.WebControls.TextBox
System.Windows.Forms.TextBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification