For more information about how to write ActiveX programs, see my Blog C # compile ActiveX Control http://blog.csdn.net/hndkbadxv/article/details/9084167
Step 1: Add a method and an attribute to the control class
Public String shownow ()
{
Return datetime. Now. tostring ();
}
Private string _ STR;
Public String Str
{// Get and set must be completely written, not just get or set
Get {return _ STR ;}
Set {_ STR = value ;}
}
Step 2: write code in HTML
Object ID = "activexdemo" name = "activexdemo" classid = "CLSID: 0a031ca1-6b7c-409d-8fc8-ffe4e0fcee94" {guid of the control Class header} width = "400px"
Height = "38" viewastext>
<Param name = "str" value = "pass control attributes with Param"/> // send a value to the STR attribute
</Object>
<Input type = "button" onclick = "alter (activexdemo. shownow ();" value = "test"> </input> // call a method
If the following prompt appears in the lower left corner of the webpage:The object does not support this attribute or method.
Solution: 1. Check whether the control Class header has only the guid attribute. If there are other attributes, delete them. For example, [GUID ("0a031ca1-6b7c-409d-8fc8-ffe4e0fcee94"), classinterface (classinterfacetype. none), comvisible (true)], delete the yellow part; repackage and deploy
2. If the same error is returned after 1 is executed, check whether the guid in the control Class header is the same as the guid in the project -- Right-click -- Property -- Application -- assembly information. If the guid is the same, change the guid to another value.
If you have any questions, leave a message for consultation.