I have a TextBox on a Web form that I'll be accessing from code. However,
I'd also like execute some Javascript when the control loses focus.
I'm a little confused since the IDE does not seem to present javascript
events when a control has the runat="server" specified. I know I can type it
in but that wouldn't that be specifying my server-side handler rather than
client script?
I'm pretty sure I need this to be a server-side control but would like to
connect some client-side script. Is this even possible?
Thanks.
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com 9 1000
On Jan 10, 9:28 am, "Jonathan Wood" <jw...@softcircuits.comwrote:
I have a TextBox on a Web form that I'll be accessing from code. However,
I'd also like execute some Javascript when the control loses focus.
I'm a little confused since the IDE does not seem to present javascript
events when a control has the runat="server" specified. I know I can type it
in but that wouldn't that be specifying my server-side handler rather than
client script?
I'm pretty sure I need this to be a server-side control but would like to
connect some client-side script. Is this even possible?
Thanks.
--
Jonathan Wood
SoftCircuits Programminghttp://www.softcircuits.com
You 'll have to add a Attributes.Add("onclick", "javascript :function")
on the server side to associate a client event handler to a server
control. {Just check on the syntax coz I've not worked on Web apps 4
sometime.}
Hope it helps.
Regards, Dina
Jonathan,
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:O7**************@TK2MSFTNGP05.phx.gbl...
I'm pretty sure I need this to be a server-side control but would like to
connect some client-side script. Is this even possible?
Yes. This should get you going - "Using JavaScript Along with ASP.NET 2.0" http://msdn2.microsoft.com/en-us/library/aa479390.aspx
HTH,
Moe
Any attribute that is not recognized on server side will just be emitted to
the client as it is. So
<asp:Text ... abc="xyz" /will produce
<input type="text" abx="xyz" />
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:O7**************@TK2MSFTNGP05.phx.gbl...
I have a TextBox on a Web form that I'll be accessing from code. However,
I'd also like execute some Javascript when the control loses focus.
I'm a little confused since the IDE does not seem to present javascript
events when a control has the runat="server" specified. I know I can type
it
in but that wouldn't that be specifying my server-side handler rather than
client script?
I'm pretty sure I need this to be a server-side control but would like to
connect some client-side script. Is this even possible?
Thanks.
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com
For lost focus you would do:
myTextBox.Attributes.Add("onblur", "javascript :myfunction")
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Jonathan Wood" wrote:
I have a TextBox on a Web form that I'll be accessing from code. However,
I'd also like execute some Javascript when the control loses focus.
I'm a little confused since the IDE does not seem to present javascript
events when a control has the runat="server" specified. I know I can type it
in but that wouldn't that be specifying my server-side handler rather than
client script?
I'm pretty sure I need this to be a server-side control but would like to
connect some client-side script. Is this even possible?
Thanks.
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com
Yep. Thanks!
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com
"Dina" <di*********@gmail.comwrote in message
news:f7**********************************@e32g2000 prn.googlegroups.com...
On Jan 10, 9:28 am, "Jonathan Wood" <jw...@softcircuits.comwrote:
>I have a TextBox on a Web form that I'll be accessing from code. However, I'd also like execute some Javascript when the control loses focus.
I'm a little confused since the IDE does not seem to present javascript events when a control has the runat="server" specified. I know I can type it in but that wouldn't that be specifying my server-side handler rather than client script?
I'm pretty sure I need this to be a server-side control but would like to connect some client-side script. Is this even possible?
Thanks.
-- Jonathan Wood SoftCircuits Programminghttp://www.softcircuits.com
You 'll have to add a Attributes.Add("onclick", "javascript:function")
on the server side to associate a client event handler to a server
control. {Just check on the syntax coz I've not worked on Web apps 4
sometime.}
Hope it helps.
Regards, Dina
That article looks like just the thing I needed.
However, there's one area that I didn't see it address: How to reference
controls by name. Because if I have a TextBox with ID="txtLbs" it actually
ends up with a name something like
"ctl00_ctl00_ContentPlaceHolder1_MainContent_Wizar d1_txtLbs". I need to
reference two controls from the javascript. I had to hard code these names
because they could potentially change. Anyone have any ideas?
Thanks.
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com
"Moe Sisko" <nullwrote in message
news:uJ**************@TK2MSFTNGP03.phx.gbl...
Jonathan,
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:O7**************@TK2MSFTNGP05.phx.gbl...
>I'm pretty sure I need this to be a server-side control but would like to connect some client-side script. Is this even possible?
Yes. This should get you going - "Using JavaScript Along with ASP.NET
2.0" http://msdn2.microsoft.com/en-us/library/aa479390.aspx
HTH,
Moe
My concern was that it might match one of the ASP.NET control's server-side
events/attributes. But perhaps most of those have different names.
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:ew**************@TK2MSFTNGP06.phx.gbl...
Any attribute that is not recognized on server side will just be emitted
to
the client as it is. So
<asp:Text ... abc="xyz" /will produce
<input type="text" abx="xyz" />
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:O7**************@TK2MSFTNGP05.phx.gbl...
>I have a TextBox on a Web form that I'll be accessing from code. However, I'd also like execute some Javascript when the control loses focus.
I'm a little confused since the IDE does not seem to present javascript events when a control has the runat="server" specified. I know I can type
it
>in but that wouldn't that be specifying my server-side handler rather than client script?
I'm pretty sure I need this to be a server-side control but would like to connect some client-side script. Is this even possible?
Thanks.
-- Jonathan Wood SoftCircuits Programming http://www.softcircuits.com
Heh, I looked at a table of javascript events had didn't relate to onblur
being when a control lost focus. That name only makes sense in an odd sort
of way. Cool.
I also found a good article based on another suggestion. But do you have any
ideas how I would reference other controls from javascript, given that the
IDs of ASP.NET controls can change substantially by the time the HTML is
rendered?
Thanks!
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com
"Peter Bromberg [C# MVP]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:A8**********************************@microsof t.com...
For lost focus you would do:
myTextBox.Attributes.Add("onblur", "javascript:myfunction")
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Jonathan Wood" wrote:
>I have a TextBox on a Web form that I'll be accessing from code. However, I'd also like execute some Javascript when the control loses focus.
I'm a little confused since the IDE does not seem to present javascript events when a control has the runat="server" specified. I know I can type it in but that wouldn't that be specifying my server-side handler rather than client script?
I'm pretty sure I need this to be a server-side control but would like to connect some client-side script. Is this even possible?
Thanks.
-- Jonathan Wood SoftCircuits Programming http://www.softcircuits.com
Looks like I got this working. I used the ClientID property to obtain the
final control ID.
Thanks!
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:e2**************@TK2MSFTNGP06.phx.gbl...
That article looks like just the thing I needed.
However, there's one area that I didn't see it address: How to reference
controls by name. Because if I have a TextBox with ID="txtLbs" it actually
ends up with a name something like
"ctl00_ctl00_ContentPlaceHolder1_MainContent_Wizar d1_txtLbs". I need to
reference two controls from the javascript. I had to hard code these names
because they could potentially change. Anyone have any ideas?
Thanks.
--
Jonathan Wood
SoftCircuits Programming http://www.softcircuits.com
"Moe Sisko" <nullwrote in message
news:uJ**************@TK2MSFTNGP03.phx.gbl...
>Jonathan,
"Jonathan Wood" <jw***@softcircuits.comwrote in message news:O7**************@TK2MSFTNGP05.phx.gbl...
>>I'm pretty sure I need this to be a server-side control but would like to connect some client-side script. Is this even possible?
Yes. This should get you going - "Using JavaScript Along with ASP.NET 2.0" http://msdn2.microsoft.com/en-us/library/aa479390.aspx
HTH, Moe
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michelle Keys |
last post by:
I am trying to call a print function to print a string from a database
using javascript.
Which is RC_DATA of Varchar2(2500).
This is a javascript is not being used. I have a thing that needs to...
|
by: Hazzard |
last post by:
I just realized that the code I inherited is using all asp.net server
controls (ie. webform controls) and when I try to update textboxes on the
client side, I lose the new value of the textbox when...
|
by: David |
last post by:
I am running into situtations where confining all forms to just one window
(instance of broswer) is becoming overly restrictive. Does ASP.NET provide
ways to have multiple windows to interact with...
|
by: Bill Jones |
last post by:
I'm trying to use this.RegisterStartupScript to add some javascript to and
aspx page that will run when the page is loaded. Does anyone know if this
function only works in the Page_Load function? ...
|
by: Leo |
last post by:
I have a datagrid with the first column as a Edit,Update,Cancel button
column. The other 5 columns are template columns. When I click the Edit
button in IE6 the row correctly displays the...
|
by: epigram |
last post by:
I'm going to be building an asp.net appliction. Something typical that I
imagine is I will have a .aspx page that will have multiple controls in a
form. The user can make changes to the controls...
|
by: Diana M |
last post by:
Hello,
I have started my first asp.net application (beginner). I have 2 text
boxes on the form that should contain 2 different dates (beginning and end).
It would be nice to have 2 small buttons...
|
by: jojobar |
last post by:
Hello,
I am trying to use vs.net 2005 to migrate a project originally in vs.net
2003. I started with creation of a "web site", and then created folders for
each component of the site.
I read...
|
by: Joey |
last post by:
I am going to use a collection of either div HTML server controls or
panel web server controls (renders as div on newer browsers) on a web
form. I need to be able to hide them with a client-side...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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...
|
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...
| |