Solved

Accessing a class from cleint side code

Posted on 2003-11-04
3
348 Views
Last Modified: 2012-08-14
I have the following in my global.asa:

Dim x

Set Application("x") = Server.CreateObject("Something.clsSomthing")

End Sub

I have been calling this as follows from server side code:

SomeVar = Application("x").SomeMethod

Now I'm having to use client side script as I'm using an MSFlexgrid, so how do I access ("x") from the client side? Basically how can I get SomeVar = Application("x").SomeMethod to work in client side code.

Looking forward to your help.

Matt.
0
Comment
Question by:Matt_Unsworth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 200 total points
ID: 9677852
you should realize that your class is on the server, and your script is on the client.

There are 2 ways to do what you want:

- copy the class to client script wile loading the page

<script>
//simplest way: just get everything you might need in different clientside variables
myvar1 = '<%=Application("x").SomeMethod%>';
myvar2 = '<%=Application("x").SomeOtherMethod%>';
</script>


- use some asynchronic way to go to the server and fetch the value. Like XMLHTTP. Those methods are highly browser dependent.
XMLHTTP works in IE only. As do xml-dataislands.


0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 9678090
you would have to use the method described by sybe above.. or do a post to the server and execute the method.

Cheers!!
0
 

Author Comment

by:Matt_Unsworth
ID: 9685846
mmmmmm…….. this is proving more difficult than I first thought.

What I’m trying to do is place a number in a texbox then click a button which does the following:

1) Convert texbox value to variable
2) Pass variable to my class
3) Return results in an MSFlexGrid

My code is below, but at the moment it’s going into error at:
AgreementSearchResult = <%=Application("x").SearchByAgreement(AgreementVar)%>

and returning the following:

An exception of type 'Response object: 006~ASP 0185~Missing Default property was not found for the object.’ Was not handled.

<SCRIPT LANGUAGE=vbscript>
Sub cmdAgreementSearch_OnClick
Dim AgreementVar
Dim AgreementSearchResult

'  Control validation
If txtAgreementSearch.value = "" Then
Msgbox "ERROR: Please enter an agreement number"
Exit Sub
End If

' convert user id to string variable, password already converted
'AgreementVar = txtAgreementSearch.value

' Bring x from the server to client side
AgreementSearchResult = <%=Application("x").SearchByAgreement(AgreementVar)%>


'  Get an array back from the class and populate the MSFlexGrid with it
Dim i

MSFlexGrid1.Rows = UBound(AgreementSearchResult, 2) + 1
MSFlexGrid1.Cols = 11
MSFlexGrid1.FixedCols=0
MSFlexGrid1.FixedRows=1

msgbox "Rows = " & UBound(AgreementSearchResult, 2) + 1

' Assign headers
MSFlexGrid1.TextMatrix(0, 1) = "ID"
MSFlexGrid1.ColWidth(1) = 2000
MSFlexGrid1.TextMatrix(0, 2) = "Name"
MSFlexGrid1.ColWidth(2) = 2000
MSFlexGrid1.TextMatrix(0, 3) = "Agreement"
MSFlexGrid1.ColWidth(3) = 2000
MSFlexGrid1.TextMatrix(0, 4) = "Claim"
MSFlexGrid1.ColWidth(4) = 2000
MSFlexGrid1.TextMatrix(0, 5) = "Type"
MSFlexGrid1.ColWidth(5) = 2000
MSFlexGrid1.TextMatrix(0, 6) = "Category"
MSFlexGrid1.ColWidth(6) = 2000
MSFlexGrid1.TextMatrix(0, 7) = "Sub-Category"
MSFlexGrid1.ColWidth(7) = 2000
MSFlexGrid1.TextMatrix(0, 8) = "Department"
MSFlexGrid1.ColWidth(8) = 2000
MSFlexGrid1.TextMatrix(0, 9) = "Open Date"
MSFlexGrid1.ColWidth(9) = 2000
MSFlexGrid1.TextMatrix(0, 10) = "Close Date"
MSFlexGrid1.ColWidth(10) = 2000
MSFlexGrid1.TextMatrix(0, 11) = "Assigned To"
MSFlexGrid1.ColWidth(11) = 2000

' Set grid's width (?)
'MSFlexGrid1.width = MSFlexGrid1.ColWidth(0) + MSFlexGrid1.ColWidth(1) + MSFlexGrid1.ColWidth(2) + MSFlexGrid1.ColWidth(3) + MSFlexGrid1.ColWidth(4) + MSFlexGrid1.ColWidth(5)

if UBound(AgreementSearchResult) > 0 then
      'call Populate_Array x
      for i = 1 to Ubound(AgreementSearchResult, 2)
            MSFlexGrid1.TextMatrix(i, 0) = TestArray(1, i)
            MSFlexGrid1.TextMatrix(i, 1) = TestArray(2, i) & " " & TestArray(3, 1) & " " & TestArray(4, 1)
            MSFlexGrid1.TextMatrix(i, 2) = TestArray(11, i)
            MSFlexGrid1.TextMatrix(i, 3) = TestArray(12, i)
            MSFlexGrid1.TextMatrix(i, 4) = TestArray(13, i)
            MSFlexGrid1.TextMatrix(i, 5) = TestArray(14, i)
            MSFlexGrid1.TextMatrix(i, 6) = TestArray(15, i)
            MSFlexGrid1.TextMatrix(i, 7) = TestArray(23, i)
            MSFlexGrid1.TextMatrix(i, 8) = TestArray(16, i)
            MSFlexGrid1.TextMatrix(i, 9) = TestArray(17, i)
            MSFlexGrid1.TextMatrix(i, 10) = TestArray(22, i)
      next
else
      msgbox "Failed"
end if
End Sub
</SCRIPT>
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Questions about INCLUDE FILES 2 46
ASP/VB email question 4 72
Save ms data to server side. 19 64
Hide and Unhide Table 6 42
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question