Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing Server script from Client script - HELP!

Status
Not open for further replies.

computergeek

Programmer
May 23, 2001
193
CA
Hello,

I am trying to perform some validation on this Server-side, and return a string or boolean basically signifying if validation passed or failed. If failed I want a msgbox to display informing the user, and if validation passed I want to go to another asp page.
Problems encountered:
1. Cannot use msgbox on server-side to client if invalid
2. Cannot access session variable on client side, therefore I can't perform my validation (NT Auth is saved in session variable, this is done within the global.asa)
3. Cannot seem to execute server-side script from client function?
4. Cannot use response.redirect from client script

I have done some reading on Remote scripting... this may be the solution, but I do not know enough about it to say at this point. HELP, I'm stuck!

Below is an example of my code (that does not work):
Client-Side script:
function validateuser_onlick()
msgbox fvalidate_security()
end function

Server-Side script:
function fvalidate_security()
fvalidate_security = "This is a test - Access Denied"
end if

Thanks,
Darlene
 
You must realize that a webpage in your browser has no connection with the server. Your page can act like a program by using scripts *that are on the page*.
Eg: a validation function for a field is a typical example.
But when a validation requires a database lookup, you can not do that with a direct call to a server-script.
Eg: validation of a user login. Your login.asp page presents a user-id and password field, and after a submit another page is called. In that page the id/pwd is requested and used for the actual lookup.

You also must realize that your .ASP file is interpreted *by the server* and the result is send to the browser. You can not use server-side scripting commands/functions (like response.redirect) on the client side. br
Gerard
 
There are five ways (at least).
1. Normal round trip.
User fills in the form, press submit, the server checks the values entered into the form if OK, move to the next web page (redirect), if not then resend original page with an appropriate message in the page text. This is the usual method (assuming that you cannot validate on the client). Using Textbox DTC's (Design-time controls) makes this very easy.

2. Use Visual Interdev PageObject DTC.
Add a server-side script function. Add this function to the PageObject 'Execute Methods' list. In the Client Side script simply say
var retValue = thisPage.execute.<functionname(params)>;
Note1: VI should pop-up the function name and list the required parameters.
NOTE2: This uses a Java applet to open up a second http channel between client and server. Some organisations have banned Java for some crass reason, causing this to fail. (or the user has not installed the Java runtime with the browser).

3. Create a Layer (Netscape) or a Div (IE), position them so they are not visible. These can send/recieve information from the server without upsetting the main page. Cant remember what to do next!

4. Use XML and the XMLDOM. Don't ask for more details!

5. Use ASP.Net or SOAP toolkit ver 2, to create some WebServices to perform the required valiation functions. A bit leading-edge but it should work well. (Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top