: : : : :
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).