Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
AnswerRe: Combo+GroupBox Pin
Expert Coming18-May-11 10:38
Expert Coming18-May-11 10:38 
AnswerRe: Combo+GroupBox Pin
RobCroll19-May-11 6:19
RobCroll19-May-11 6:19 
QuestionCall a function of other form [modified] Pin
MiguelSanchezCuarental18-May-11 5:03
MiguelSanchezCuarental18-May-11 5:03 
AnswerRe: Call a function of other form Pin
Wayne Gaylard18-May-11 5:47
professionalWayne Gaylard18-May-11 5:47 
AnswerRe: Call a function of other form Pin
Icharus18-May-11 5:51
Icharus18-May-11 5:51 
AnswerRe: Call a function of other form Pin
DaveyM6918-May-11 9:30
professionalDaveyM6918-May-11 9:30 
AnswerRe: Call a function of other form Pin
RobCroll19-May-11 6:34
RobCroll19-May-11 6:34 
QuestionIHTMLDOCUMENT2 and using all property to modify the webpage Pin
Member 70956418-May-11 4:23
Member 70956418-May-11 4:23 
I have a problem, that is to mask data in certain format that is displayed in the browser

To solve the problem I came up with the following solution

1)Find all the browser window handles (class Internet Explorer_server)
2)Get the IHTMLDOCUMENT2 using the window handle
3)Use IHTMLDOCUMENT2::body::innerHTML to find the data I am looking for and modify it.

The code I have written below throws a COMException. [Could not set the innerHTML property. Invalid target element for this operation.]

//document is a IHTMLDOCUMENT2 obtained using the window handle and WM_HTML_GETOBJECT message
//pattern is StringBuilder initialized with a SSN pattern that I want to mask.
IHTMLElementCollection dome = document.all;
foreach (IHTMLElement dom in dome)
{
 StringBuilder bf = new StringBuilder(dom.innerHTML);
 if (bf.ToString().Contains(pattern.ToString()))
 {
  bf.Replace(pattern.ToString(), "***-**-****");
  dom.innerHTML = bf.ToString(); //Exception occurs here
 }
}


Why does this exception occur. How do I fix it so that the webpage contents will be altered.


I wrote another version of the code, it works, but not completely.
I found out that is because the webpage contains multiple frames and so it does not work. I does not work if the SSN number is inside a frame(or something like a frame which holds an embeded object).
StringBuilder bf = new StringBuilder(document.body.innerHTML);
if (bf.ToString().Contains(pattern.ToString()))
{

    bf.Replace(pattern.ToString(), "***-**-****");
    document.body.innerHTML = bf.ToString();
}


The first piece of code throws exceptions, the second one does not work if there are multiple frames.

What am I doing wrong in both the code above.

How do I go about achieving my solution. Is my approach correct, or is there a better way to do it.

Thanks and regards,
David
QuestionBuild Multiuser Network application Pin
hemant saliya18-May-11 1:12
hemant saliya18-May-11 1:12 
AnswerRe: Build Multiuser Network application Pin
Wayne Gaylard18-May-11 1:15
professionalWayne Gaylard18-May-11 1:15 
AnswerRe: Build Multiuser Network application Pin
Pete O'Hanlon18-May-11 1:24
mvePete O'Hanlon18-May-11 1:24 
GeneralRe: Build Multiuser Network application Pin
Luc Pattyn18-May-11 3:56
sitebuilderLuc Pattyn18-May-11 3:56 
AnswerRe: Build Multiuser Network application Pin
Keith Barrow18-May-11 2:24
professionalKeith Barrow18-May-11 2:24 
AnswerRe: Build Multiuser Network application Pin
PIEBALDconsult18-May-11 2:46
mvePIEBALDconsult18-May-11 2:46 
AnswerRe: Build Multiuser Network application Pin
jschell18-May-11 7:01
jschell18-May-11 7:01 
QuestionHow to get CheckBox Control from Datagridview in Windows form...? Pin
Manish_Kumar_Nayak18-May-11 1:00
Manish_Kumar_Nayak18-May-11 1:00 
AnswerRe: How to get CheckBox Control from Datagridview in Windows form...? Pin
Wayne Gaylard18-May-11 1:12
professionalWayne Gaylard18-May-11 1:12 
QuestionWCF Throttling Behavior settings Pin
teknolog12318-May-11 0:39
teknolog12318-May-11 0:39 
QuestionRe: WCF Throttling Behavior settings Pin
Mark Salsbery18-May-11 6:08
Mark Salsbery18-May-11 6:08 
AnswerRe: WCF Throttling Behavior settings Pin
teknolog12319-May-11 22:31
teknolog12319-May-11 22:31 
GeneralRe: WCF Throttling Behavior settings Pin
Mark Salsbery20-May-11 4:01
Mark Salsbery20-May-11 4:01 
QuestionControl integrity of ZIP files Pin
abbd18-May-11 0:30
abbd18-May-11 0:30 
AnswerRe: Control integrity of ZIP files Pin
Eddy Vluggen18-May-11 10:35
professionalEddy Vluggen18-May-11 10:35 
QuestionEnumerating directories/shares (and their Permissions) [modified] Pin
devvvy17-May-11 23:25
devvvy17-May-11 23:25 
AnswerRe: Enumerating directories/shares (and their Permissions) [modified] Pin
devvvy18-May-11 21:09
devvvy18-May-11 21:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.