Posted By

sekihin on 09/14/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Dynamically create ActiveX object


 / Published in: C#
 

  1. HtmlGenericControl rdp = new HtmlGenericControl("object");
  2. rdp.Attributes["id"] = "rdp";
  3. rdp.Attributes["name"] = "rdp";
  4. rdp.Attributes.Add("classid",
  5. "clsid:7584c670-2274-4efb-b00b-d6aaba6d3850");
  6. rdp.Attributes["runat"] = "server";
  7. rdp.Attributes["width"] = "1034";
  8. rdp.Attributes["height"] = "778";
  9. Page.Controls.Add(rdp);
  10.  
  11. string rdpConnect = "function Button1_onclick()" +
  12. "{" +
  13. "rdp.Width=1034;" +
  14. "rdp.Height=778;" +
  15. "rdp.DesktopWidth=1024;" +
  16. "rdp.DesktopHeight=768;" +
  17. "rdp.Server=text1.value;" +
  18. "rdp.Connect();" +
  19. "}";
  20.  
  21. string rdpDisconnect = " function disconnect()" +
  22. "{" +
  23. "rdp.Disconnect();" +
  24. "}";
  25.  
  26. rdpFunctions.InnerHtml = rdpConnect;
  27. rdpFunctions.InnerHtml = rdpFunctions.InnerHtml +
  28. rdpDisconnect;
  29. Page.Controls.Add(rdpFunctions);

Report this snippet  

You need to login to post a comment.