954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Without postback

Guys i have a textbox where user enters a telephone number , i need to check in the database whether there a same telephone number in the database already , i want this to happen as soon as the textbox looses focus without posting back , is there any way to accomplish this is asp ????

deceivingrakesh
Light Poster
41 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Without a postback means you will need to use AJAX. You say "is there any way to accomplish this is asp". Do you mean in ASP (active server pages) or are you using .net and you meant asap?

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 168
 

I meant asp .net , and i meant page without refreshing when i meant postback .

deceivingrakesh
Light Poster
41 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

In that case you defineitely want to use AJAX. Which is pretty easy in ASP.Net.
Go here http://www.asp.net/ajax and download the AJAX tool kit. Add it as a reference to your projectand you will see extra options appear in the IDE tool kit.

Basically you add an AJAX manager to the page and define which part of the page is going to use AJAX by placing a template control around the correct controls. The webiste above has tutorials that will step you through it.

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 168
 

aside from ajax, which is very handy,
you can also try to use a webmethod

http://forums.asp.net/t/1528982.aspx

Cruize_Invades
Light Poster
40 posts since May 2007
Reputation Points: 6
Solved Threads: 7
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script>
function checkForInvalid(obj) {
	if( /[^0-9\-]|-{2,}/gi.test(obj.value) ) {
		alert("Invalid character in Invoice No.")
		obj.value = ""; // line added to clear textbox value
		obj.focus();
		// obj.select(); // line removed
		return false;
	}
	return true;
}

</script>
</head>

<body>
<form name="myForm">
<input type="text" name="invoiceNo" onkeyup="checkForInvalid(this)">
</form>
</body>
</html>

Try this will help you

mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: 0
Solved Threads: 7
 

Thank you all for replying :)

deceivingrakesh
Light Poster
41 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

i have a new problem !!!!! in "log off" function i have written the code to update cookie values to null , but when the user presses the back button the page comes up again but if the user presses any button then it doesn't work , i want to know how to make the user not see the page when they press back button

deceivingrakesh
Light Poster
41 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

you can clear the history. is that what you want?

Cruize_Invades
Light Poster
40 posts since May 2007
Reputation Points: 6
Solved Threads: 7
 

nope , clearing the history ll del everything !!!! but i dont want the pages related to the particular site to be removed from cache ,

and i ahve a new proble , it might sound stupid !!!!
lets say i have 3 textboxes and a button

i need to validate in such a way when the user clicks button , if one of the textboxes are empty it should throw exception , now i know how to do this both in javascript and in serverside vb script , but what i dont understand is when the user clicks button will the javascript gets executed first or serverside vb code , because if the textboxes are null server side vb code should not get executed .

deceivingrakesh
Light Poster
41 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Hey,
For the logging off/back button issue, are you using session state to record the user's logged in status? if yes, when they logout clear the session. Then if they go back your page should check (if you have coded it to do so) if the user is still logged in or not with the session and deny them.

Question 2, client side gets fired first but you may want to use validation controls to check for valid input. These fire before the page is posted back and if the textbox is empty, input is incorrect, etc postback stops and a message can be presented to the user.

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 168
 
i need to validate in such a way when the user clicks button , if one of the textboxes are empty it should throw exception , now i know how to do this both in javascript and in serverside vb script , but what i dont understand is when the user clicks button will the javascript gets executed first or serverside vb code , because if the textboxes are null server side vb code should not get executed .

javascript is executed first. now when you determine that one of the textbox is empty.

if(document.getElementById('textboxt1').value == null ||document.getElementById('textboxt2').value == null || document.getElementById('textboxt3').value == null)
{
-- some logic --
return false;
}
else{
-- some logic --
return true;
}


return false would stop the execution of the severside code.

Cruize_Invades
Light Poster
40 posts since May 2007
Reputation Points: 6
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You