Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessing a class from cleint side code

Posted on 2003-11-04
3
Medium Priority
?
363 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 600 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 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