aelatik
asked on
ActiveX & ASP interaction
Hi,
I know how to build controls and use it in VB but what i need to know is how to pass data from an activeX control to a webpage.
For example i have an ActiveX control containing a Richt Textbox.
How can i store the content of the RichtTextbox to a database ( serverside ).
all i need to know is how to pass the data back to HTML/ASP ( not how to process it against the database )
PSEUDO CODE :
<%
If Request("UserControl1") <> "" then <<< This is what i need to know
' Store the richttextcontent in the database
end if
<HTML>
<HEAD>
</HEAD>
<BODY>
<OBJECT ID="UserControl1"
CLASSID="CLSID:5C769028-F4 30-4243-B9 F6-FB69904 BCCE0"
CODEBASE="Project1.CAB#ver sion=1,0,0 ,0">
</OBJECT>
</BODY>
</HTML>
I know how to build controls and use it in VB but what i need to know is how to pass data from an activeX control to a webpage.
For example i have an ActiveX control containing a Richt Textbox.
How can i store the content of the RichtTextbox to a database ( serverside ).
all i need to know is how to pass the data back to HTML/ASP ( not how to process it against the database )
PSEUDO CODE :
<%
If Request("UserControl1") <> "" then <<< This is what i need to know
' Store the richttextcontent in the database
end if
<HTML>
<HEAD>
</HEAD>
<BODY>
<OBJECT ID="UserControl1"
CLASSID="CLSID:5C769028-F4
CODEBASE="Project1.CAB#ver
</OBJECT>
</BODY>
</HTML>
ASKER
EDDYKT, I used the following :
AX Control >>>
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
Public Event SendMessage(ByVal Mess As String)
Private Sub Command1_Click()
RaiseEvent SendMessage(RichTextBox1.T extRTF)
End Sub
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
ASP Page >>>
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
<HTML><HEAD></HEAD><BODY>
<xml type="text/xml" src="" id=XMLDoc1></xml>
<OBJECT ID="UserControl1"
CLASSID="CLSID:5C769028-F4 30-4243-B9 F6-FB69904 BCCE0"
CODEBASE="Project1.CAB#ver sion=1,0,0 ,0">
</OBJECT>
<script language="VBSCRIPT">
Sub UserControl1_SendMessage(m essage)
XMLDoc1.src = "Serverside.asp?MESSAGE=" & message
End Sub
<SCRIPT></BODY></HTML>
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
This does not work, nothing happens ???
AX Control >>>
--------------------------
Public Event SendMessage(ByVal Mess As String)
Private Sub Command1_Click()
RaiseEvent SendMessage(RichTextBox1.T
End Sub
--------------------------
ASP Page >>>
--------------------------
<HTML><HEAD></HEAD><BODY>
<xml type="text/xml" src="" id=XMLDoc1></xml>
<OBJECT ID="UserControl1"
CLASSID="CLSID:5C769028-F4
CODEBASE="Project1.CAB#ver
</OBJECT>
<script language="VBSCRIPT">
Sub UserControl1_SendMessage(m
XMLDoc1.src = "Serverside.asp?MESSAGE=" & message
End Sub
<SCRIPT></BODY></HTML>
--------------------------
This does not work, nothing happens ???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, The messagebox gets triggered. But Serverside.asp is NOT.
This is what i have put temporarily in serverside.asp
<%
Dim FSO, TEXTSTREAM
Set FSO = Server.CreateObject("Scrip ting.FileS ystemObjec t")
Set TEXTSTREAM = FSO.CreateTextFile("c:\fil e.txt", True, False)
TEXTSTREAM.WriteLine (Request("MESSAGE"))
Set TEXTSTREAM = Nothing
Set FSO = Nothing
%>
This is what i have put temporarily in serverside.asp
<%
Dim FSO, TEXTSTREAM
Set FSO = Server.CreateObject("Scrip
Set TEXTSTREAM = FSO.CreateTextFile("c:\fil
TEXTSTREAM.WriteLine (Request("MESSAGE"))
Set TEXTSTREAM = Nothing
Set FSO = Nothing
%>
Try this on Serverside.asp
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
Dim FSO, TEXTSTREAM, str
Set FSO = Server.CreateObject("Scrip ting.FileS ystemObjec t")
Set TEXTSTREAM = FSO.CreateTextFile("c:\fil e.txt", True, False)
str = Request.QueryString("MESSA GE")
TEXTSTREAM.WriteLine (str)
Set TEXTSTREAM = Nothing
Set FSO = Nothing
Response.Write "<DATA>" & str & "</DATA>"
</SCRIPT>
Add this on the first asp file inside the script tag
Sub XMLDoc1_onreadystatechange ()
Dim ResponseStr
On Error Resume Next
If XMLDoc2.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
This way you will see the message loop back to your html page
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
Dim FSO, TEXTSTREAM, str
Set FSO = Server.CreateObject("Scrip
Set TEXTSTREAM = FSO.CreateTextFile("c:\fil
str = Request.QueryString("MESSA
TEXTSTREAM.WriteLine (str)
Set TEXTSTREAM = Nothing
Set FSO = Nothing
Response.Write "<DATA>" & str & "</DATA>"
</SCRIPT>
Add this on the first asp file inside the script tag
Sub XMLDoc1_onreadystatechange
Dim ResponseStr
On Error Resume Next
If XMLDoc2.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
This way you will see the message loop back to your html page
Correction
Sub XMLDoc1_onreadystatechange ()
Dim ResponseStr
On Error Resume Next
If XMLDoc2.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
to
Sub XMLDoc1_onreadystatechange ()
On Error Resume Next
If XMLDoc1.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
Sub XMLDoc1_onreadystatechange
Dim ResponseStr
On Error Resume Next
If XMLDoc2.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
to
Sub XMLDoc1_onreadystatechange
On Error Resume Next
If XMLDoc1.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
ASKER
Still nothing, serverside.asp is not triggered.
Are they in the same directory?
Can you also post the first asp file
Try to do the sample test
on the first asp
<html>
<head>
</head>
<SCRIPT LANGUAGE=VBScript>
sub button_onclick()
XMLDoc1.src = "Serverside.asp?MESSAGE=" & "message"
end sub
Sub XMLDoc1_onreadystatechange ()
On Error Resume Next
If XMLDoc1.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
</SCRIPT>
<body>
<xml type="text/xml" src="" id=XMLDoc1></xml>
<input type="button" value="Button" id="button" name="B3"></p>
</body>
</html>
on the second asp
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
Dim str
str = Request.QueryString("MESSA GE")
Response.Write "<DATA>" & str & "</DATA>"
</SCRIPT>
This works for me
on the first asp
<html>
<head>
</head>
<SCRIPT LANGUAGE=VBScript>
sub button_onclick()
XMLDoc1.src = "Serverside.asp?MESSAGE=" & "message"
end sub
Sub XMLDoc1_onreadystatechange
On Error Resume Next
If XMLDoc1.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
</SCRIPT>
<body>
<xml type="text/xml" src="" id=XMLDoc1></xml>
<input type="button" value="Button" id="button" name="B3"></p>
</body>
</html>
on the second asp
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
Dim str
str = Request.QueryString("MESSA
Response.Write "<DATA>" & str & "</DATA>"
</SCRIPT>
This works for me
ASKER
It works for me, I see the message box.
You can change some message on the second asp, and see whether i can read it
8->
You can change some message on the second asp, and see whether i can read it
8->
ASKER
This is the second page :
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
Dim str
str = Request.QueryString("MESSA GE")
Response.Write "<DATA>" & str & "</DATA>"
</SCRIPT>
It's supposed to do a response.write
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
Dim str
str = Request.QueryString("MESSA
Response.Write "<DATA>" & str & "</DATA>"
</SCRIPT>
It's supposed to do a response.write
I said I click on your link and click the button
I see the message with
<DATA>message</DATA>
on the msgbox. You said you don't have msgbox coming up?
I see the message with
<DATA>message</DATA>
on the msgbox. You said you don't have msgbox coming up?
ASKER
I have a messagebox comming up, that is not the problem.
The problem is passing the data in the messagebox to serverside.asp
The problem is passing the data in the messagebox to serverside.asp
wait a minute, if you see the message
<DATA>message</DATA>
on the messagebox, that means the serverside.asp has been call the return the string you pass from the first ASP. Do I miss something here?
Sub XMLDoc1_onreadystatechange ()
On Error Resume Next
If XMLDoc1.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
The above routine is call the server side to your XML data island. That mean your serverside.asp has been called.
<DATA>message</DATA>
on the messagebox, that means the serverside.asp has been call the return the string you pass from the first ASP. Do I miss something here?
Sub XMLDoc1_onreadystatechange
On Error Resume Next
If XMLDoc1.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml
End If
End Sub
The above routine is call the server side to your XML data island. That mean your serverside.asp has been called.
ASKER
You are right, i changed is to <test> and indeed the serverside.asp file is triggered.
But why is it running local instead of server ? Response.write should not give messageboxes ?
But why is it running local instead of server ? Response.write should not give messageboxes ?
>>Response.write should not give messageboxes ?
you are right
However, this does
Sub XMLDoc1_onreadystatechange ()
On Error Resume Next
If XMLDoc1.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml '''''' this does
End If
End Sub
The response.write actually write the data (message) back to XML data island and you display message box on the client side
you are right
However, this does
Sub XMLDoc1_onreadystatechange
On Error Resume Next
If XMLDoc1.readyState = "complete" Then
msgbox XMLDoc1.XMLDocument.xml '''''' this does
End If
End Sub
The response.write actually write the data (message) back to XML data island and you display message box on the client side
That is one way you don't have to reload the entire asp instead use XML data island to perform as a bridge between client and server
ASKER
Im going to try an insert with ADODB serverside.
ASKER
OK, i tested it. What happens is as follows :
The first page shows a messagebox containing the parsed results from serverside.asp.
The ADODB Instert command on the serverside page does not fire.
This is serverside now ( which does not work ) :
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
Dim DS, str
DS = "dsn=MYDSN;"
str = Request.QueryString("MESSA GE")
set RS= Server.CreateObject("ADODB .Command")
RS.ActiveConnection = DS
RS.CommandText = "INSERT INTO TABLENAME (FIELDNAME) VALUES ('" & str & "')"
RS.CommandType = 1
RS.CommandTimeout = 0
RS.Prepared = true
RS.Execute()
</SCRIPT>
The first page shows a messagebox containing the parsed results from serverside.asp.
The ADODB Instert command on the serverside page does not fire.
This is serverside now ( which does not work ) :
<SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
Dim DS, str
DS = "dsn=MYDSN;"
str = Request.QueryString("MESSA
set RS= Server.CreateObject("ADODB
RS.ActiveConnection = DS
RS.CommandText = "INSERT INTO TABLENAME (FIELDNAME) VALUES ('" & str & "')"
RS.CommandType = 1
RS.CommandTimeout = 0
RS.Prepared = true
RS.Execute()
</SCRIPT>
You may want to debug your code and see what's the problem
ie
on error resume next
str = Request.QueryString("MESSA GE")
set RS= Server.CreateObject("ADODB .Command")
if (err.number) then
response.write err.number & " " & err.description
endif
RS.ActiveConnection = DS
RS.CommandText = "INSERT INTO TABLENAME (FIELDNAME) VALUES ('" & str & "')"
etc
ie
on error resume next
str = Request.QueryString("MESSA
set RS= Server.CreateObject("ADODB
if (err.number) then
response.write err.number & " " & err.description
endif
RS.ActiveConnection = DS
RS.CommandText = "INSERT INTO TABLENAME (FIELDNAME) VALUES ('" & str & "')"
etc
Is it a security problem?
Any luck?
ASKER
Its weird, no error is raised ??
Does your server side code works from VB. If yes, then mostly likely is security
ASKER
EDDYKT,
I do not have much time left to spend on this Q. I will get back to it in the future within a new question ofcourse.
Anyways, thanks for the effort...
I do not have much time left to spend on this Q. I will get back to it in the future within a new question ofcourse.
Anyways, thanks for the effort...
ie
Public Event SendMessage(ByVal Mess As String)
some where in the code
you can call
RaiseEvent SendMessage("your richtextbox string here"
In your asp
Sub UserControl1_SendMessage(m
On Error Resume Next
' to pass data back to server
XMLDoc1.src = "Serverside.asp?MESSAGE=" & message
End Sub
<BODY>
<xml type="text/xml" src="" id=XMLDoc1></xml>
....
</Body>Serverside.asp
You can write the string back to database by using Serverside.asp