PDA

Click to See Complete Forum and Search --> : Easy Question on ASP


T
Apr 21st, 2000, 12:54 AM
New to ASP. Can't quite figure out the following.

HTP Page on CLIENT has a button and a textbox. User Clicks on button which runs CLIENT side script which request as ASP page on SERVER. The ASP page creates an active X object which does some processing and then returns to the ORIGINAL CLIENT page, a datastream (not HTTP formatted) which the CLIENT puts into the TextBox.

Note: the ASP page is not supposed to display anything, only create and Active X SERVER object which will return to the requesting CLIENT page, information which it will use via CLIENT side server scripts.

thinh
Apr 21st, 2000, 06:48 PM
are you trying to make a redirecting script? cause it's sounds like it...

Apr 21st, 2000, 09:55 PM
If you requested a page from the server via http your gonna get back via http. This is what should happen with your page:

Sample client side script(as seen before it is sent to the client, so it has some asp in it):

<%
Dim strUserName
strUserName = Trim(Request("UserName"))
%>
<html>
<title>MyClientPage.asp</title>
<body bgcolor="FFFFFF">
<form name="MyHtmlForm" method="POST" action="MyAspProcessingPage.asp">
<input type="text" size="20" name="UserName" value="<%= strUserName %>">
<input type="submit" value=" Save ">
</form>
</body>
</html>


that should display a single textbox and a button with the word Save on it within the browser. Now let's say the user types in jack handy for the username and presses submit. The information will now be "posted" to the page "MyAspProcessingPage.asp" which might look like the following:


<%
Dim strUserName, objYourActiveXServerObject

strUserName = Trim(Request("UserName"))

set objYourActiveXServerObject = _
Server.CreateObject("ServerName.ClassName")

' let's say all your server component does is
' capitalize the first letter of each word using
' a wrapper around the VB6 built in function StrConv.

strUserName = objYourActiveXServerObject.MyStrConv(strUserName)

Set objYourActiveXServerObject = Nothing

' Now send the newly formatted username back
' to the same page you started out with.
Response.Redirect "http://server/MyClientPage.asp?UserName=" & _
Server.URLEncode (strUserName)
%>


(fyi, StrConv is not available in VBScript, also, Request("UserName") is not a typo, depending on the circumstance it can be ok to not include .Form or .QueryString)

so when the client page first starts it tries to get the username using the request object. It doesn't find it so when you first see the client page the box is empty.

the user then types in the name jack handy and presses the submit button. Your server side only script, "MyAspProcessingPage.asp", will grab the username, your wrapper method, MyStrConv(which does one thing, capitalizes the first letter of every word), converts the username it was passed. Once complete it will send the new username back to the first page.

when the first page tries to get the username this time it succeeds and displays Jack Handy in the text box.