Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

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>
0
alexthecodepoet
Asked:
alexthecodepoet
  • 2
1 Solution
 
appariCommented:
try adding runat="server" to the object declaration
0
 
alexthecodepoetAuthor Commented:
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
0
 
alexthecodepoetAuthor Commented:
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..
0
 
GhostModCommented:
Closed, 500 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now