473,721 Members | 2,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HtmlElement.Out erHtml.Replace( ) fails with COM exception

Dev env: VS 2005 C# Express, .Net Framework 2.0

I am trying to programmaticall y select an item in a listbox on a web
page. The first thing I do is go through and de-select any selected
items. The OuterHtml field of a selected element in the listbox looks
something like this:

<OPTION value=* selected>Defaul t item</OPTION>

I want to simply remove the the term 'selected' this way:

elt.OuterHtml = elt.OuterHtml.R eplace("selecte d","");

This results in OuterHtml being set to:

<OPTION value=* selected></OPTION>

Notice: 1) the 'selected' term is untouched, 2) the visible text has
been removed.

After the assignment I can see in the debugger that one of the members
of the HtmlElement object (OffsetParent, I think) has a string
indicating some kind of COM Interop services exception.

Is it possible to change the HTML in a web page? Am I going about it
the wrong way? Is there some kind of initialization or setup call I am
supposed to make? Is it just a bug in .NET 2.0?

Apr 25 '06 #1
1 3541
The MSDN documentation at


does contain this warning:

"If you assign a new value to OuterHtml, the current element reference
will become invalid; it will not reflect the name, properties and child
content of the HTML you have just assigned."

but I don't really understand what that means.

Apr 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Pai | last post by:
Hello there, I have the following peice of javascript which works with IE but would not work with mozilla. In IE the first for loop is entered but in mozilla i would not enter the for loop any tips / ideas? var tblObj=document.body.getElementsByTagName("TD")
by: Jason Keirstead | last post by:
Is there a way I can add a setter/getter to the HTMLElement prototype in internet explorer? This, for example, works fine in Mozilla: HTMLElement.prototype.__defineSetter__("foobar", function (sFoobar) { alert( sFoobar ); });
by: harry | last post by:
Using IE 5.5 (sp2) - no other I have a table that need's to be sorted by single column using javascript. I have the code to do this but because of the attributes associated with the <tr> element, when the sorted values are copied back in to the table I want to replace the entire row not just the inner values! Any ideas why this doesn't work?
by: Richard | last post by:
In understanding how this works, would it not be possible then to replace an item with another? For instance, I have the first paragraph of "Lorem Ipsum" shown in a division. At the bottom is a ling showing "next". Click on the link, the next paragraph replaces te previous. <p id="lorem1">lorem ipsum stuff.</p> <p id="lorem2">paragraph 2 stuff.</p>
by: Christopher Benson-Manica | last post by:
How do you extend HTMLElement? Why can't you just do HTMLElement.prototype.foo=function() { alert( 'foo' ); } I assume HTMLElement belongs to some kind of namespace, but darn if I can find anything that tells me anything about it. --
by: prasaddevivara | last post by:
I am using the outerHTML property to modify the HTML of existin elements in a web page in Internet Explorer. But same outerHTM property is not working in firefox browser, Anybody can tell me a alternative for outerHTML property in firefox. I am using th following function to display an image and alternate text behind al images of a weg page in Internet Explorer. Anybody can give solutio for same in firefox browser. function...
by: MeNotHome | last post by:
I am automating the navigation of a website. When I reach the end, it changes to xml. So my axwebbrowser1 has a bunch of xml data in it. So here is what I am trying to do Dim xmlText As String Dim doc As New XmlDocument() Dim myElem As XmlElement
by: AMDRIT | last post by:
Hello Everyone, We have a production WinForms Application that uses a WebBrowser to display readonly data. In the html document we have SPAN elements that facilitate menu selections. We also have a TABLE object that is bound to an XML Data Island, each row of the table has an option to "View Details" or "Delete" When a user clicks a SPAN object we would set the WebBrowser's Status Text to the desired command, then back to "Ready". ...
by: marchaos | last post by:
I'm trying to override the native HTMLElement.addEventListener in firefox so that I can do some extra things. I know it's possible to add methods to the HTMLElement prototype and for them to be present on instances of that element, but modifying native methods doesn't seem to stick ie: HTMLElement.prototype.addEventListener = function() { alert('overridden'); };
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.