index > Visual C# General > HtmlDocument and Object Tag

HtmlDocument and Object Tag

Greetings,

i have a question regarding the HtmlDocument class. Im building a small app that integrates the WebBrowser. At runtime i want to add applets to the source code.

Although i can add the applets, there is a small problem:

This is the code i want to generate in the Browser:
<object style="position:absolute; top: 1px; left: 1px" codetype="application/java" classid="..." width="10" height="10">
<param name="code" value="..." />
<param name="codebase" value="..." />
</object>

Unfortunally, i cant seem to be able to add any child elements to the object element... this is the code i am using:



public static void AddNewEditor(HtmlDocument document, Point point)

{

HtmlElement
element, param;

element = document.CreateElement(
"object");

element.SetAttribute(
"codetype", "application/java");

element.SetAttribute(
"classid", "...");

element.SetAttribute(
"id", "editor");

element.Style =
"width=1; height=1; position:absolute; top: " + point.Y + "px; left:
"
+ point.X + "px";

document.Body.AppendChild(element);

param = document.CreateElement(
"param");

param.SetAttribute(
"name", "code");

param.SetAttribute(
"value", "...");

element.AppendChild(param);


param = document.CreateElement(
"param");

param.SetAttribute(
"name", "codebase");

param.SetAttribute(
"value", "...");

element.AppendChild(param);

}


 


i cant seem to call the element.AppendChild(param);... but it should ve a valid child for object...

I tried all i could think of, as editing the inner html of the object tag, etc, but nothng seems to work... Sad Any clue??

Thanks in advance Big Smile
Caxaria




Caxaria
Caxaria
In most cases you cannot modify the <param>s of an <object> tag after it has been rendered to the browser, try appending the params to the <object> before appending the <object> to the document <body>.


Senior .NET Architect - Bennett Adelson, MCSD.NET, MCAD
Ron A. Buckton
Ron, thanks for your reply Smile

Actually as soon as i create the object tag, it has the property CanHaveChildren as false.

Trying to add a param element creates an exception, even before adding the object to the HtmlDocument.

Creating other tag's, like div, allows the HtmlElement to have children... but what i really need is to add an applet to the html... You dont know of a workaround?




Caxaria
Caxaria

Finally i've been able to had the applet... instead of using the <object> tag, i used the <applet> and defined all the params as attributes to the tag (This should not be done this way, i read somewhere, as the <object> is the correct form but... :)

Anyway, now the applet does not run unless there was an applet running before on the page i am changing. Does anyone know how to make my instance of the WebBrowser to start the JVM?

Thanks,
Caxaria




Caxaria
Caxaria
reply 4

You can use google to search for other answers

 

More Articles

• Creating DOS-like Windows
• How can I pivot results from the DataGridView into my update func...
• SaveAll
• filling a listview in
• interacting sql server 2000 and c# .net
• execute something by another thread CHALLENGE!!!!!
• How do I pass a class to another form?
• try within try
• TreeView
• Converting document files (.doc, .rtf) to .pdf format using .net
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Batch build
• install fails for c# 2003 standard
• The best way to clip and store an image
• Inheritence of web forms
• Hosting ASP.Net runtime in Winforms app
• Debugger hangs in thread after breakpoint
• problem in adding reference to a DLL file
• gridView with DataSourceID to be determi
• Error 1324: The folder path 'n/a' contai
• drawing something to the form---
• character literal for escape
• Serialization And Changing The Operating
• Using CDOEX
• Print Forms.Panel
• try within try

Hot Articles

• How to: notification pop up message
• GridView Control RowCommand
• Using Excel to graph?
• method not firing
• e.Graphics = picCapture.CreateGraphics();
• wanting to read/write image files - .bmp
• sql
• convert a string to date but whith new f
• creating timed or demo version of my app.
• Special Assignement
• Problem of ListView and Image Problem
• Finding SSID using .NET2005
• Insert Command
• Multiple Inheritence
• Could not load file or assembly 'Crystal

Recommend Articles

• AppBar without importing API's ?
• How to set Internet Explorer Printer Pag
• Converting
• Where can I buy Visual C# 2005 Standard
• Fastest possible update of a Bitmap
• Accessing Body tag
• [OTP] running DOS commands using C#
• remove the RowSelector
• strange button onclick behavior
• Retrieving Hardware key giving problem
• Create Excell sheets
• why is this error?
• Error when attempting to register
• Assigning permissions to external proces
• Async Programming...