473,671 Members | 2,326 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 3536
The MSDN documentation at

http://tinyurl.com/edbln

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

3
11259
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")
2
8531
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 ); });
4
17207
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?
1
1302
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>
1
3141
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. --
1
13292
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...
25
2953
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
1
2520
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". ...
5
5292
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'); };
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8596
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,...
0
8667
tracyyun
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...
0
7428
agi2029
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...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4221
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...
1
2806
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
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1801
bsmnconsultancy
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.