Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2006, 09:10 AM
Authorized User
 
Join Date: Jan 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default JavaScript Problem

Respected Sir,
                i seem to be having quite a problem trying to validate my asp.net webform...using javascript....My webform contains 2 textboxes and a button which is used to submit the form. (both the textboxes and button are webcontrols).... everytime i click the submit button i have called a javascript function in the aspx page using btn.Attributers.Add("onclick","functionName") ...if initially the txtboxes are empty...an alert is raised when i click the btn....which is what it shoul be doing....now if i fill both the textboxes after that and i click the button i still get the alert ...only if i click the button twice the alert goes away.... please could u tell me what the problem is...and give me a little advise on what i should do...the code that i have written is somethin like this


codebehind:(C#)
//let btn be button
//txt1 be textbox1
// txt2 be textbox2

private void Page_Load(Object sender,EventArgs e)
{
this.btn.Attributes.Add("onclick","validateFor m()");
}

protected void btn_Clicked(Object sender,EventArgs e)
{
if(txt1.Text==""||txt2.Text=="")
{
     string incompleteForm="<script>" +
                         "alert('Incomplete From')" +
                         "</script>"
}
else
{
     //connectToDatabase
}
}


achhetri
__________________
achhetri
 
Old April 3rd, 2006, 10:26 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Use required field validators.

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Problem suresh_accudocs ASP.NET 1.0 and 1.1 Professional 1 July 24th, 2007 06:04 PM
problem with javascript padmaja3 Other Programming Languages 0 February 8th, 2007 02:56 AM
javascript problem dk6607 ASP.NET 1.0 and 1.1 Basics 10 October 2nd, 2006 12:56 PM
Javascript Problem dparsons ASP.NET 1.0 and 1.1 Basics 2 March 22nd, 2006 01:41 PM
Javascript problem highcliffevillage Javascript How-To 0 July 8th, 2004 07:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.