Link to home
Start Free TrialLog in
Avatar of alexthecodepoet
alexthecodepoet

asked on

help accessing objects

Hello,

I have the following code (see below).

Why is it that if i try to access objActiveX using inline C# asp.net code,
(the       <%  string s = "Original Text";)

, it doesn't work.  i get this:
 'System.Web.UI.HtmlControls.HtmlForm' does not contain a definition for 'objActiveX'

but the 2nd example (using Javascript), does?

I need a way to access it using C# instead of Javascript.  Does anyone know a solution?


Thanks,

code######################




<form runat="server" id="mainform">      
            <OBJECT id="objActiveX" height="1" width="1"
                        classid="bin/ActiveX.dll#mynamespace.cwdActiveXClass"
                        VIEWASTEXT>
                  </OBJECT>
                  <%
                string s = "Original Text";
                mainform.objActiveX.strModifiableString = s;
                Response.Write(s);                
                  %>

                  <script language="javascript">
              var a = mainform.objActiveX.modifyword();
              document.write(a);
              </script>
</form>
Avatar of appari
appari
Flag of India image

try adding runat="server" to the object declaration
Avatar of alexthecodepoet
alexthecodepoet

ASKER

that wouldn't make sense, as the object is supposed to be run client side, since its an activeX component.

plus, that doesn't work
i got it to work by doing this:

    void Page_Load(object s, EventArgs e)
    {
        hiddenSessionID.Value = Session.SessionID.ToString();
    }

                       <input id="hiddenSessionID" value="hello world" runat="server"  />
             <script type="text/javascript" language="javascript">
                        mainform.objActiveX.strModifiableString = document.getElementById("hiddenSessionID").value;
              var a = mainform.objActiveX.modifyword();
              document.write(a);
              </script>

so basically, i use the hidden input field as an inbetween layer for javascript and C# to talk..
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial