473,804 Members | 3,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to implement an onclick on asp:TextBox?

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
Nov 18 '05 #1
7 2276
Jan,

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

Eliyahu

"Jan Hoffman" <ho*********@ho tmail.com> wrote in message
news:el******** ******@TK2MSFTN GP14.phx.gbl...
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

Nov 18 '05 #2
Try this:
<asp:TextBox RunAt=Server Id="name" onClick="this.s elect();" />

"Jan Hoffman" <ho*********@ho tmail.com> wrote in message
news:el******** ******@TK2MSFTN GP14.phx.gbl...
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

Nov 18 '05 #3
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" <sh******@onlin e.excite.com> schrieb im Newsbeitrag
news:ON******** ********@TK2MSF TNGP14.phx.gbl. ..
Try this:
<asp:TextBox RunAt=Server Id="name" onClick="this.s elect();" />

"Jan Hoffman" <ho*********@ho tmail.com> wrote in message
news:el******** ******@TK2MSFTN GP14.phx.gbl...
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

Nov 18 '05 #4
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" <ho*********@ho tmail.com> wrote in message
news:O1******** ******@TK2MSFTN GP12.phx.gbl...
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" <sh******@onlin e.excite.com> schrieb im Newsbeitrag
news:ON******** ********@TK2MSF TNGP14.phx.gbl. ..
Try this:
<asp:TextBox RunAt=Server Id="name" onClick="this.s elect();" />

"Jan Hoffman" <ho*********@ho tmail.com> wrote in message
news:el******** ******@TK2MSFTN GP14.phx.gbl...
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


Nov 18 '05 #5
how can I impelent it with code behind?
Jan

"Eliyahu Goldin" <re************ *@monarchmed.co m> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
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" <ho*********@ho tmail.com> wrote in message
news:O1******** ******@TK2MSFTN GP12.phx.gbl...
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" <sh******@onlin e.excite.com> schrieb im Newsbeitrag
news:ON******** ********@TK2MSF TNGP14.phx.gbl. ..
> Try this:
> <asp:TextBox RunAt=Server Id="name" onClick="this.s elect();" />
>
> "Jan Hoffman" <ho*********@ho tmail.com> wrote in message
> news:el******** ******@TK2MSFTN GP14.phx.gbl...
> 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
>
>
>



Nov 18 '05 #6
Hi,
You use the Attributes collection: Text1.Attribute s.Add ("onClick",
"this.select(); "); // C#

"Jan Hoffman" <ho*********@ho tmail.com> wrote in message
news:uf******** ******@TK2MSFTN GP09.phx.gbl...
how can I impelent it with code behind?
Jan

"Eliyahu Goldin" <re************ *@monarchmed.co m> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
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" <ho*********@ho tmail.com> wrote in message
news:O1******** ******@TK2MSFTN GP12.phx.gbl...
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" <sh******@onlin e.excite.com> schrieb im Newsbeitrag
news:ON******** ********@TK2MSF TNGP14.phx.gbl. ..
> Try this:
> <asp:TextBox RunAt=Server Id="name" onClick="this.s elect();" />
>
> "Jan Hoffman" <ho*********@ho tmail.com> wrote in message
> news:el******** ******@TK2MSFTN GP14.phx.gbl...
> 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
>
>
>




Nov 18 '05 #7
One way is to put a line (c# syntax)

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

in the page's PreRender event handler.

Eliyahu

"Jan Hoffman" <ho*********@ho tmail.com> wrote in message
news:uf******** ******@TK2MSFTN GP09.phx.gbl...
how can I impelent it with code behind?
Jan

"Eliyahu Goldin" <re************ *@monarchmed.co m> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
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" <ho*********@ho tmail.com> wrote in message
news:O1******** ******@TK2MSFTN GP12.phx.gbl...
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" <sh******@onlin e.excite.com> schrieb im Newsbeitrag
news:ON******** ********@TK2MSF TNGP14.phx.gbl. ..
> Try this:
> <asp:TextBox RunAt=Server Id="name" onClick="this.s elect();" />
>
> "Jan Hoffman" <ho*********@ho tmail.com> wrote in message
> news:el******** ******@TK2MSFTN GP14.phx.gbl...
> 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
>
>
>



Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7902
by: Alex | last post by:
I am a newbie to ASP.NET... What I was trying to do... but yet to succeed in... I am building a customer info database... and on default, I want to display the customer's basic information in the TextBox on Page_Load... but, also allow user to update the information For example: Street1 of the home address
2
5295
by: Kerri | last post by:
Hi, I have an asp textbox that allows users to enter their password. I have another page that allows a user to edit their user account. On this page I set the text to be the password in the Database. There is a value in my datareader but yet on my
1
12298
by: Ed West | last post by:
Hello, How can I put a textbox control into a cell of an asp:Table? I was not able to do it from the properties sheet, so I put it in via html tab, but now I can't select it from the Design tab (nor select it from the Properties tab on the right). Any ideas? <asp:Table id="Table1" runat="server"> <asp:TableRow> <asp:TableCell Text="Email:"></asp:TableCell>
1
3025
by: Shilpi Chaudhry | last post by:
I have a forloop which I use to create textboxes - but unfortunately all of them have the same ids - I need to assign different ids to these textboxes creeated in the loop so that I can retrieve their corrs values. Anybody?? Code snippet: <% int y = 7; %>
0
1441
by: Luis Esteban Valencia | last post by:
am trying to databind within an asp:textbox control. I have tried many variations found here but nothing seems to work. It works fine if I use a regular HTML textbox input though. Here is what I have tried: <asp:textbox id='<%#DataBinder.Eval(Container.DataItem, "EmailID")%>' cssclass="textbox" runat="server"><%#DataBinder.Eval(Container.DataItem, "Email")%></asp:textbox> I get '<%# DataBinder.Eval(Container.DataItem,...
3
2129
by: Patrick | last post by:
Try to put in a TextBox next month's date in format (MMM yyyy). The following does NOT work, why is that? <!--When rendered, the texbox is blank, although the text in the round bracket after the textbox is rendered correctly as (July, 2005)--> <asp:TextBox id="MonthTextBox" runat="server"><%=System.DateTime.Now.ToString("y")%></asp:TextBox> (<%=System.DateTime.Now.ToString("y")%>) <!--Same again. defaultMonth is initialised as early...
0
10560
by: datakix | last post by:
After 16 hours of frustration, I've managed to solve this problem for a project I'm working on. The 'trick' is set EnableViewState="False" for the asp:textbox inside the Repeater control. The problem is that by default the asp:textbox ViewState is True. This means that the textbox value is automatically preserved between postback (saved in the __VIEWSTATE hidden field and restored during a page postback).
0
1621
by: CharlesA | last post by:
Hi folks, I'm using ASP.net 1.1 with C# I've got this kind of thing going <div class="row"> <label class="col1">Rm Name</label> <asp:textbox id="txtRM" runat="server" cssclass="col2" ReadOnly="True" EnableViewState="False"></asp:textbox> <label class="col3">Rm Phone</label> <asp:textbox id="txtRmPhone" runat="server" cssclass="col4" ReadOnly="True"
0
3507
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table to white the used CSS to set the opacity to 90 so that you can see the background image through the table. The problem I am having is with the textboxes in the transparent
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.