473,466 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

TextBox1 value

hey all,
i'm trying to use the onblur client-side event to get the value of TextBox1
but can't seem to nail down the syntax. can someone please help?

thanks,
rodchar
Nov 12 '07 #1
9 3887
On Nov 12, 8:54 pm, rodchar <rodc...@discussions.microsoft.comwrote:
hey all,
i'm trying to use the onblur client-side event to get the value of TextBox1
but can't seem to nail down the syntax. can someone please help?

thanks,
rodchar
you can use Attributes.Add

TextBox1.Attributes.Add("onblur","...");

Nov 12 '07 #2
<asp:textbox id="textbox1"
runat="server"
onblur="alert(this.value);" />

-- bruce (sqlwork.com)

rodchar wrote:
hey all,
i'm trying to use the onblur client-side event to get the value of TextBox1
but can't seem to nail down the syntax. can someone please help?

thanks,
rodchar
Nov 12 '07 #3
On Nov 12, 9:35 pm, bruce barker <nos...@nospam.comwrote:
<asp:textbox id="textbox1"
runat="server"
onblur="alert(this.value);" />

-- bruce (sqlwork.com)
hm... bruce, are you sure? onblur is a DOM event, it's not an
attribute of the TextBox server control

Nov 12 '07 #4
If asp.net doesn't recognize an attribute, it will just render it as it is:

<asp:textbox id="textbox1" runat="server" abc="xyz" />

will render as

<input type="text" id="textbox1" abc="xyz" />

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
On Nov 12, 9:35 pm, bruce barker <nos...@nospam.comwrote:
><asp:textbox id="textbox1"
runat="server"
onblur="alert(this.value);" />

-- bruce (sqlwork.com)

hm... bruce, are you sure? onblur is a DOM event, it's not an
attribute of the TextBox server control

Nov 13 '07 #5
On Nov 13, 10:07 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
If asp.net doesn't recognize an attribute, it will just render it as it is:

<asp:textbox id="textbox1" runat="server" abc="xyz" />

will render as

<input type="text" id="textbox1" abc="xyz" />

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
Well, this would make a warning regarding wrong attribute and when you
have treat warnings as errors turned on you will not be able to build
the project (code-behind). So, is this the best way?

You can also use <input runat="server" onblur=....

Nov 13 '07 #6
I am not saying it is the best way, I am saying it will work.

I personally use the Attributes collection, and I definitely like <input
runat="server" onblur=....more than <asp:textbox runat="server" onblur=....

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@v2g2000hsf.googlegro ups.com...
On Nov 13, 10:07 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>If asp.net doesn't recognize an attribute, it will just render it as it
is:

<asp:textbox id="textbox1" runat="server" abc="xyz" />

will render as

<input type="text" id="textbox1" abc="xyz" />

--
Eliyahu Goldin,
Software Developer
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

Well, this would make a warning regarding wrong attribute and when you
have treat warnings as errors turned on you will not be able to build
the project (code-behind). So, is this the best way?

You can also use <input runat="server" onblur=....

Nov 13 '07 #7
Hi Im trying to add the onfocus event to a textbox contained in datalist. I
can add the attribute but the code just doesnt work.

I can add a texbox to a web page and in code behind add following ;

Me.TextBox1.Attributes.Add("onfocus", "this.value='';")
Me.TextBox1.Attributes.Add("onblur", "this.value='Click here';")

This works great, how can you do it with the textbox in a datalist. I can
the attribute the same by using the ItemCommand event but the javascript does
not work.

Thanks

Neil

"Eliyahu Goldin" wrote:
I am not saying it is the best way, I am saying it will work.

I personally use the Attributes collection, and I definitely like <input
runat="server" onblur=....more than <asp:textbox runat="server" onblur=....

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@v2g2000hsf.googlegro ups.com...
On Nov 13, 10:07 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
If asp.net doesn't recognize an attribute, it will just render it as it
is:

<asp:textbox id="textbox1" runat="server" abc="xyz" />

will render as

<input type="text" id="textbox1" abc="xyz" />

--
Eliyahu Goldin,
Software Developer
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
Well, this would make a warning regarding wrong attribute and when you
have treat warnings as errors turned on you will not be able to build
the project (code-behind). So, is this the best way?

You can also use <input runat="server" onblur=....


Nov 16 '07 #8
I haven't used a DataList, but for most list-based controls there is a
"ItemCreated" event. Inside that event you can get references to template
controls using (Sender as DataList).FindByName("ControlName").
I can add a texbox to a web page and in code behind add following ;

Me.TextBox1.Attributes.Add("onfocus", "this.value='';")
Me.TextBox1.Attributes.Add("onblur", "this.value='Click here';")

This works great, how can you do it with the textbox in a datalist.
Nov 16 '07 #9
Yep I have used the event ItemCreated as such ;

Dim tmpTextBox As TextBox
tmpTextBox = CType(e.Item.FindControl("txtQty"), TextBox)
tmpTextBox.Attributes.Add("onfocus", "this.value='';")

Ive found out that the code works in firefox the way I want but its IE not
playing ball, so Im just trying to find out why. ? hate problems like this ,
a nice error msg would have been helpfull.

Neil

"Scott Roberts" wrote:
I haven't used a DataList, but for most list-based controls there is a
"ItemCreated" event. Inside that event you can get references to template
controls using (Sender as DataList).FindByName("ControlName").
I can add a texbox to a web page and in code behind add following ;

Me.TextBox1.Attributes.Add("onfocus", "this.value='';")
Me.TextBox1.Attributes.Add("onblur", "this.value='Click here';")

This works great, how can you do it with the textbox in a datalist.

Nov 16 '07 #10

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

Similar topics

5
by: Hareth | last post by:
Is there a way to take a text, from a textbox & later passwordChar the text. I'm not using a masked textbox. I tried: textBox1.PasswordChar = '*'; but this didn't change my text. I know how...
7
by: al | last post by:
Greetings all, I use request.form("textbox1") to get data back to page, dim str as string str = request.form("textbox1").tostring But str is always empty after refresh???? I use asp.net...
4
by: I_AM_DON_AND_YOU? | last post by:
A simple query: I have a textbox with multiline=true. Also there is a button1. In button1's click the code written is textbox1.lines(0) = "Microsoft" textbox2.lines(1) = "Visual Basic" ...
4
by: Ken Soenen | last post by:
The code below illustrates my problem which is: I'm trying to access the TEXT from TextBox1 which is on Form1. Line "aa = Form1.TextBox1.Text" produces the error--Reference to a non-shared member...
5
by: Pohihihi | last post by:
Why can't the following work when it has a set property defined? this.textBox1.Size.Width = 25; I get error Cannot modify the return value of 'System.Windows.Forms.Control.Size' because it is...
2
by: dbfrey | last post by:
This is the oddest thing I've ever seen. We have an aspx page with some user controls, one is a main, another is a status, which has an edit button. on the main control, we have some dropdowns...
1
by: emailseshu | last post by:
Hi, Iam trying to check the Client Side CallBack Feature in ASP.NET Iam able to call th RaiseCallbackEvent from the Client Side Javascript Function but when I go to the debug mode to check the...
3
by: Mark Ivey | last post by:
VS.Net 2002 - Visual Basic I am pretty new to VB in general, and I am having a bit of difficulty finding the right method or property to link a textbox to a filelistbox. Here is the...
0
by: ricklafleur | last post by:
I'm using CSharp/ASP.NET 2.0 and trying to create a simple search page that records the user query in the URL (so can be bookmark) and also re-writes the query int the original TextBox. This only...
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.