0

I have a 3rd part control(it is a COM and it is not a server control).

 <object id="SigPlus1" classid="clsid:69A40DA3-4D42-11D0-86B0-0000C025864A" 
            name="SigPlus1" style="left: 0px; width: 544px; top: 0px; height: 86px">
    <param name="_Version" value="131095">
       <param name="_ExtentX" value="14393">
         <param name="_ExtentY" value="2275">
            <param name="_StockProps" value="9"></param>
         </param>
        </param>
    </param>
   </object>

In the C# code behind I use:

object o = (Page.FindControl("SigPlus1")

There is no error but o is set to null.

I know this object has a property named colormode, how can set this in the code behind

2
  • You don't have runat="server" on that tag, that means it's not a control and therefore FindControl isn't going to find it. Commented Apr 24, 2015 at 19:29
  • also your casting is off take a look at msdn Page.FindControl method Commented Apr 24, 2015 at 19:30

2 Answers 2

2

Try to add runat = "server"

<object id="SigPlus1" runat="server" classid="clsid:69A40DA3-4D42-11D0-86B0-0000C025864A" name="SigPlus1" style="left: 0px; width: 544px; top: 0px; height: 86px">

and if you dont want to add the runat = "server" then you can use like

var SigPlus1 = Request.Form["SigPlus1"];
Sign up to request clarification or add additional context in comments.

4 Comments

var SigPlus1 = Request.Form["SigPlus1"]; would only get posted form values. It wouldn't get a control reference.
@mason:- Yes very correct! The the only option is to have runat = "server"
I cannot run it as server i get an error. I include the error message as soon as i get to my computer
In order to change to using 'Runat=server': The above answer should have mentioned that all current page script references, if any exist, in your aspx page, need to be converted to this example format document.getElementByID('<%=SigPlus1.ClientID%>')
1

Add the runat="server" attribute to the <object> element. Then you can find it in the code behind.

<object id="SigPlus1" runat="server" ...>

Code behind

var SigPlus1 = Page.FindControl("SigPlus1");

Or if the control is not in a templated control you can access it directly via it's ID without needing Page.FindControl().

3 Comments

This tag, somehow does not let to add runat server. I asked the dev person why and he told me because this is a COM control(interop)
@SNash what do you mean does not let you? Need details.
Im on the bus but I post tge error messae as soo as i get home.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.