473,395 Members | 1,677 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,395 software developers and data experts.

Problem in using "Button1.Attributes.Add " for client side script for Validations

In my form I and doing validations using 'Javascript' as I m using
ASP1.1 and there is very less support for Validators there.
//Code Behind
private void Page_Load(object sender, System.EventArgs e)
{
Button1.Attributes.Add("OnClick","fun()");
}
Problem in using "Button1.Attributes.Add " for client side script for
Validations

private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write("Hello, World");
}
//Client Side Script

<script language="javascript">

function fun()
{
if (document.Form1.TextBox1.value != '')
{
alert("Hello");
return true;
}
else
{
alert("World")
return false;
}
}

</script>
What I need to do is, if TextBox1 is Empty, Response.Write("Hello,
World") should not get executed, i.e. The Code written in Button should
not be executed.

What Should I do??

Thanks and Regards
Anup

Mar 2 '06 #1
1 5846
OK,
I got the problem,

Code should be like :-
Button1.Attributes.Add("OnClick","return fun()");
and not like:-
Button1.Attributes.Add("OnClick","fun()");

Anup wrote:
In my form I and doing validations using 'Javascript' as I m using
ASP1.1 and there is very less support for Validators there.
//Code Behind
private void Page_Load(object sender, System.EventArgs e)
{
Button1.Attributes.Add("OnClick","fun()");
}
Problem in using "Button1.Attributes.Add " for client side script for
Validations

private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write("Hello, World");
}
//Client Side Script

<script language="javascript">

function fun()
{
if (document.Form1.TextBox1.value != '')
{
alert("Hello");
return true;
}
else
{
alert("World")
return false;
}
}

</script>
What I need to do is, if TextBox1 is Empty, Response.Write("Hello,
World") should not get executed, i.e. The Code written in Button should
not be executed.

What Should I do??

Thanks and Regards
Anup


Mar 2 '06 #2

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

Similar topics

10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
4
by: Shawn Mason | last post by:
I have a requirment to utilize popup windows for edit/add screens from datagrids. I have accomplished this using client-side javascript. I have been told this is not acceptable and I must do it...
1
by: Lau Lei Cheong | last post by:
I have an aspx page which have the following code segment: <script> // I do something here template = "<input id=\"hidden_info_1\" type=\"hidden\" runat=\"server\"> // I do other things here...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
1
by: Anup | last post by:
Hi Group, In my project I m using "RequiredFieldValidator" for the validations of text box, There are two TextBox, say "txtBox1" and "txtBox2" now I want to make either of TextBox mandatory,...
0
by: joshyparameswar | last post by:
Hi , Can anybody help me in the following issue . Problem --------- Interdev is not stopping in the client side script.The scripts are working ...
4
by: mubarak basha | last post by:
hi, i want to display the corresponding users system time in my html page of my website using client side script.......how can i do this.......please give some coding or suggestions...........
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
1
by: Anja N | last post by:
I was wondering if there is any way to change language settings or Input mode of IME language toolbar using client side script.
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.