473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Javascript in a .net page

I have a .net text field and a .net button on a form.

When the user leaves the text field server side VB.net code fires to check
if anything has been entered and if it has, enables the button.

The problem with this is that it has to do the round trip to the server.

How would I use javascript to do this in a .net page ?
Can I control a .net textbox with javascript ?

TIA
Nov 18 '05 #1
2 1069
yes, by all means you can use javascript to control the elements in your
page. to disable the asp:button add the disabled attribute and set it to
true

<asp:Button id="Button1" disabled=true style="Z-INDEX: 102; LEFT: 176px;
POSITION: absolute; TOP: 232px" runat="server"
Text="Button"></asp:Button>

now you add events to the textbox. I used a combination of keyup and keydown

<asp:TextBox id="TextBox1" onKeyUp="enablebutton();"
onKeyDown="enablebutton();" style="Z-INDEX: 101; LEFT: 176px; POSITION:
absolute; TOP: 184px"
runat="server"></asp:TextBox>

then the javascript

<script language=javascript>
<!--
function enablebutton()
{

if(Form1.TextBox1.value != "")
{
Form1.Button1.disabled = false;
}
else
{
Form1.Button1.disabled = true;
}
}
//-->
</script>

HTH

Jose


"Poppy" <pa**********@NOSPAMthemedialounge.com> wrote in message
news:OP**************@TK2MSFTNGP10.phx.gbl...
I have a .net text field and a .net button on a form.

When the user leaves the text field server side VB.net code fires to check
if anything has been entered and if it has, enables the button.

The problem with this is that it has to do the round trip to the server.

How would I use javascript to do this in a .net page ?
Can I control a .net textbox with javascript ?

TIA

Nov 18 '05 #2
Thankyou

"Jose L Rodriguez" <jo**********@hotmail.com> wrote in message
news:#h**************@TK2MSFTNGP09.phx.gbl...
yes, by all means you can use javascript to control the elements in your
page. to disable the asp:button add the disabled attribute and set it to
true

<asp:Button id="Button1" disabled=true style="Z-INDEX: 102; LEFT: 176px;
POSITION: absolute; TOP: 232px" runat="server"
Text="Button"></asp:Button>

now you add events to the textbox. I used a combination of keyup and keydown
<asp:TextBox id="TextBox1" onKeyUp="enablebutton();"
onKeyDown="enablebutton();" style="Z-INDEX: 101; LEFT: 176px; POSITION:
absolute; TOP: 184px"
runat="server"></asp:TextBox>

then the javascript

<script language=javascript>
<!--
function enablebutton()
{

if(Form1.TextBox1.value != "")
{
Form1.Button1.disabled = false;
}
else
{
Form1.Button1.disabled = true;
}
}
//-->
</script>

HTH

Jose


"Poppy" <pa**********@NOSPAMthemedialounge.com> wrote in message
news:OP**************@TK2MSFTNGP10.phx.gbl...
I have a .net text field and a .net button on a form.

When the user leaves the text field server side VB.net code fires to check if anything has been entered and if it has, enables the button.

The problem with this is that it has to do the round trip to the server.

How would I use javascript to do this in a .net page ?
Can I control a .net textbox with javascript ?

TIA


Nov 18 '05 #3

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

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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
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...

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.