ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1727
Number of posts: 3292

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Alert window from a form with target _blank. Posted by shani.safeer on 15 Jun 2006 at 1:55 AM
Hi,

I am develpoing a c#.net Web Application with one form set as target="blank"
The code is:

<form id="suplierpage" method="post" target="_blank" runat="server">
---
</form>

In this form i have a text box.
When the user enters a value in the text box and clicks a button,
I want to display the alert window(javascript) to know whether the entered value is valid or not.

I tried to use the javascript for alert window in the C# code.
But when the button is clicked , the same page gets opened again with the alert window.

Please provide me a solution.
Thanks 'n Regards,
Report
Re: Alert window from a form with target _blank. Posted by raylouw on 15 Jun 2006 at 2:03 AM
This message was edited by raylouw at 2006-6-15 2:4:48

: Hi,
:
: I am develpoing a c#.net Web Application with one form set as target="blank"
: The code is:
:
: <form id="suplierpage" method="post" target="_blank" runat="server">
: ---
: </form>
:
: In this form i have a text box.
: When the user enters a value in the text box and clicks a button,
: I want to display the alert window(javascript) to know whether the entered value is valid or not.
:
: I tried to use the javascript for alert window in the C# code.
: But when the button is clicked , the same page gets opened again with the alert window.
:
: Please provide me a solution.
: Thanks 'n Regards,
:


try this:

<html>
<head>
<script language='JavaScript'>
function validate()
{
alert(document.getElementById('myTxt').value);
return false;
}
</script>
</head>
<body>
<form id="suplierpage" method="post" onsubmit="return validate();">
<input id='myTxt' type='text'>
<input type='submit'>
</form>
</body>
</html>

I think it will do what you want.




Report
Re: Alert window from a form with target _blank. Posted by shani.safeer on 15 Jun 2006 at 2:50 AM
: This message was edited by raylouw at 2006-6-15 2:4:48

: : Hi,
: :
: : I am develpoing a c#.net Web Application with one form set as target="blank"
: : The code is:
: :
: : <form id="suplierpage" method="post" target="_blank" runat="server">
: : ---
: : </form>
: :
: : In this form i have a text box.
: : When the user enters a value in the text box and clicks a button,
: : I want to display the alert window(javascript) to know whether the entered value is valid or not.
: :
: : I tried to use the javascript for alert window in the C# code.
: : But when the button is clicked , the same page gets opened again with the alert window.
: :
: : Please provide me a solution.
: : Thanks 'n Regards,
: :
:
:
: try this:
:
: <html>
: <head>
: <script language='JavaScript'>
: function validate()
: {
: alert(document.getElementById('myTxt').value);
: return false;
: }
: </script>
: </head>
: <body>
: <form id="suplierpage" method="post" onsubmit="return validate();">
: <input id='myTxt' type='text'>
: <input type='submit'>
: </form>
: </body>
: </html>
:
: I think it will do what you want.
:
:
:
:
:



Thanks for ur reply.
My form contains more than one (button and textbox.)
The same validation needs to be done for other text boxes when other buttons are clicked correspondingly.
So i think i cant use "onsubmit".
if i can, what about other textboxes' validations?


Report
Re: Alert window from a form with target _blank. Posted by raylouw on 15 Jun 2006 at 3:09 AM
: : This message was edited by raylouw at 2006-6-15 2:4:48

: : : Hi,
: : :
: : : I am develpoing a c#.net Web Application with one form set as target="blank"
: : : The code is:
: : :
: : : <form id="suplierpage" method="post" target="_blank" runat="server">
: : : ---
: : : </form>
: : :
: : : In this form i have a text box.
: : : When the user enters a value in the text box and clicks a button,
: : : I want to display the alert window(javascript) to know whether the entered value is valid or not.
: : :
: : : I tried to use the javascript for alert window in the C# code.
: : : But when the button is clicked , the same page gets opened again with the alert window.
: : :
: : : Please provide me a solution.
: : : Thanks 'n Regards,
: : :
: :
: :
: : try this:
: :
: : <html>
: : <head>
: : <script language='JavaScript'>
: : function validate()
: : {
: : alert(document.getElementById('myTxt').value);
: : return false;
: : }
: : </script>
: : </head>
: : <body>
: : <form id="suplierpage" method="post" onsubmit="return validate();">
: : <input id='myTxt' type='text'>
: : <input type='submit'>
: : </form>
: : </body>
: : </html>
: :
: : I think it will do what you want.
: :
: :
: :
: :
: :
:
:
:
: Thanks for ur reply.
: My form contains more than one (button and textbox.)
: The same validation needs to be done for other text boxes when other buttons are clicked correspondingly.
: So i think i cant use "onsubmit".
: if i can, what about other textboxes' validations?
:
:
:


Ok what about something like this:

<html>
<head>
<script language='JavaScript'>
function validate()
{
alert(document.getElementById('myTxt').value);
return false;
}
</script>
</head>
<body>
<form id="suplierpage" method="post">
<input id='myTxt' type='text'><br>
<input type='button' onclick="validate(document.getElementById('myTxt'));" value='validate'>
</form>
</body>
</html>

Bearing in mind that an input of type button will not submit a form.

Or try using field validators:

http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=46


Report
Re: Alert window from a form with target _blank. Posted by shani.safeer on 16 Jun 2006 at 8:45 PM
: : : This message was edited by raylouw at 2006-6-15 2:4:48

: : : : Hi,
: : : :
: : : : I am develpoing a c#.net Web Application with one form set as target="blank"
: : : : The code is:
: : : :
: : : : <form id="suplierpage" method="post" target="_blank" runat="server">
: : : : ---
: : : : </form>
: : : :
: : : : In this form i have a text box.
: : : : When the user enters a value in the text box and clicks a button,
: : : : I want to display the alert window(javascript) to know whether the entered value is valid or not.
: : : :
: : : : I tried to use the javascript for alert window in the C# code.
: : : : But when the button is clicked , the same page gets opened again with the alert window.
: : : :
: : : : Please provide me a solution.
: : : : Thanks 'n Regards,
: : : :
: : :
: : :
: : : try this:
: : :
: : : <html>
: : : <head>
: : : <script language='JavaScript'>
: : : function validate()
: : : {
: : : alert(document.getElementById('myTxt').value);
: : : return false;
: : : }
: : : </script>
: : : </head>
: : : <body>
: : : <form id="suplierpage" method="post" onsubmit="return validate();">
: : : <input id='myTxt' type='text'>
: : : <input type='submit'>
: : : </form>
: : : </body>
: : : </html>
: : :
: : : I think it will do what you want.
: : :
: : :
: : :
: : :
: : :
: :
: :
: :
: : Thanks for ur reply.
: : My form contains more than one (button and textbox.)
: : The same validation needs to be done for other text boxes when other buttons are clicked correspondingly.
: : So i think i cant use "onsubmit".
: : if i can, what about other textboxes' validations?
: :
: :
: :
:
:
: Ok what about something like this:
:
: <html>
: <head>
: <script language='JavaScript'>
: function validate()
: {
: alert(document.getElementById('myTxt').value);
: return false;
: }
: </script>
: </head>
: <body>
: <form id="suplierpage" method="post">
: <input id='myTxt' type='text'>
: <input type='button' onclick="validate(document.getElementById('myTxt'));" value='validate'>
: </form>
: </body>
: </html>
:
: Bearing in mind that an input of type button will not submit a form.
:
: Or try using field validators:
:
: http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=46
:
:
:


The same problem exists(The page getting reopened).

If I am using validators,
How can i enable certain validators for certain button clicks only?

i mean--validator1 is to be enabled while Button1 is clicked.
Validator2, validator3 to be enabled for Button2 etc.





Report
Re: Alert window from a form with target _blank. Posted by raylouw on 19 Jun 2006 at 12:01 AM
: : : : This message was edited by raylouw at 2006-6-15 2:4:48

: : : : : Hi,
: : : : :
: : : : : I am develpoing a c#.net Web Application with one form set as target="blank"
: : : : : The code is:
: : : : :
: : : : : <form id="suplierpage" method="post" target="_blank" runat="server">
: : : : : ---
: : : : : </form>
: : : : :
: : : : : In this form i have a text box.
: : : : : When the user enters a value in the text box and clicks a button,
: : : : : I want to display the alert window(javascript) to know whether the entered value is valid or not.
: : : : :
: : : : : I tried to use the javascript for alert window in the C# code.
: : : : : But when the button is clicked , the same page gets opened again with the alert window.
: : : : :
: : : : : Please provide me a solution.
: : : : : Thanks 'n Regards,
: : : : :
: : : :
: : : :
: : : : try this:
: : : :
: : : : <html>
: : : : <head>
: : : : <script language='JavaScript'>
: : : : function validate()
: : : : {
: : : : alert(document.getElementById('myTxt').value);
: : : : return false;
: : : : }
: : : : </script>
: : : : </head>
: : : : <body>
: : : : <form id="suplierpage" method="post" onsubmit="return validate();">
: : : : <input id='myTxt' type='text'>
: : : : <input type='submit'>
: : : : </form>
: : : : </body>
: : : : </html>
: : : :
: : : : I think it will do what you want.
: : : :
: : : :
: : : :
: : : :
: : : :
: : :
: : :
: : :
: : : Thanks for ur reply.
: : : My form contains more than one (button and textbox.)
: : : The same validation needs to be done for other text boxes when other buttons are clicked correspondingly.
: : : So i think i cant use "onsubmit".
: : : if i can, what about other textboxes' validations?
: : :
: : :
: : :
: :
: :
: : Ok what about something like this:
: :
: : <html>
: : <head>
: : <script language='JavaScript'>
: : function validate()
: : {
: : alert(document.getElementById('myTxt').value);
: : return false;
: : }
: : </script>
: : </head>
: : <body>
: : <form id="suplierpage" method="post">
: : <input id='myTxt' type='text'>
: : <input type='button' onclick="validate(document.getElementById('myTxt'));" value='validate'>
: : </form>
: : </body>
: : </html>
: :
: : Bearing in mind that an input of type button will not submit a form.
: :
: : Or try using field validators:
: :
: : http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=46
: :
: :
: :
:
:
: The same problem exists(The page getting reopened).
:
: If I am using validators,
: How can i enable certain validators for certain button clicks only?
:
: i mean--validator1 is to be enabled while Button1 is clicked.
: Validator2, validator3 to be enabled for Button2 etc.
:
:
:
:
:
:


As far as the page being reopened goes, one of two things will cause this, your form target attrib. or that your form is runat="server". As far as the validators go, try the ControlToValidate property, but this doesnt sound as though it will help, so try using a CustomValidator, where you set the validation to be client-side and then manually do the validation in the button click event.


Report
Re: Alert window from a form with target _blank. Posted by shani.safeer on 19 Jun 2006 at 11:18 PM
: : : : : This message was edited by raylouw at 2006-6-15 2:4:48

: : : : : : Hi,
: : : : : :
: : : : : : I am develpoing a c#.net Web Application with one form set as target="blank"
: : : : : : The code is:
: : : : : :
: : : : : : <form id="suplierpage" method="post" target="_blank" runat="server">
: : : : : : ---
: : : : : : </form>
: : : : : :
: : : : : : In this form i have a text box.
: : : : : : When the user enters a value in the text box and clicks a button,
: : : : : : I want to display the alert window(javascript) to know whether the entered value is valid or not.
: : : : : :
: : : : : : I tried to use the javascript for alert window in the C# code.
: : : : : : But when the button is clicked , the same page gets opened again with the alert window.
: : : : : :
: : : : : : Please provide me a solution.
: : : : : : Thanks 'n Regards,
: : : : : :
: : : : :
: : : : :
: : : : : try this:
: : : : :
: : : : : <html>
: : : : : <head>
: : : : : <script language='JavaScript'>
: : : : : function validate()
: : : : : {
: : : : : alert(document.getElementById('myTxt').value);
: : : : : return false;
: : : : : }
: : : : : </script>
: : : : : </head>
: : : : : <body>
: : : : : <form id="suplierpage" method="post" onsubmit="return validate();">
: : : : : <input id='myTxt' type='text'>
: : : : : <input type='submit'>
: : : : : </form>
: : : : : </body>
: : : : : </html>
: : : : :
: : : : : I think it will do what you want.
: : : : :
: : : : :
: : : : :
: : : : :
: : : : :
: : : :
: : : :
: : : :
: : : : Thanks for ur reply.
: : : : My form contains more than one (button and textbox.)
: : : : The same validation needs to be done for other text boxes when other buttons are clicked correspondingly.
: : : : So i think i cant use "onsubmit".
: : : : if i can, what about other textboxes' validations?
: : : :
: : : :
: : : :
: : :
: : :
: : : Ok what about something like this:
: : :
: : : <html>
: : : <head>
: : : <script language='JavaScript'>
: : : function validate()
: : : {
: : : alert(document.getElementById('myTxt').value);
: : : return false;
: : : }
: : : </script>
: : : </head>
: : : <body>
: : : <form id="suplierpage" method="post">
: : : <input id='myTxt' type='text'>
: : : <input type='button' onclick="validate(document.getElementById('myTxt'));" value='validate'>
: : : </form>
: : : </body>
: : : </html>
: : :
: : : Bearing in mind that an input of type button will not submit a form.
: : :
: : : Or try using field validators:
: : :
: : : http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=46
: : :
: : :
: : :
: :
: :
: : The same problem exists(The page getting reopened).
: :
: : If I am using validators,
: : How can i enable certain validators for certain button clicks only?
: :
: : i mean--validator1 is to be enabled while Button1 is clicked.
: : Validator2, validator3 to be enabled for Button2 etc.
: :
: :
: :
: :
: :
: :
:
:
: As far as the page being reopened goes, one of two things will cause this, your form target attrib. or that your form is runat="server". As far as the validators go, try the ControlToValidate property, but this doesnt sound as though it will help, so try using a CustomValidator, where you set the validation to be client-side and then manually do the validation in the button click event.
:
:
:

I tried using a custom validator.Please make it clear how to set the validation to client side so that the page displays the validator in the same page(not in the reopened page).





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.