Click here to Skip to main content
15,910,787 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionSSRS 2008 Generating PDF from Report programmatically Pin
Hampden Tech19-May-11 7:11
Hampden Tech19-May-11 7:11 
AnswerRe: SSRS 2008 Generating PDF from Report programmatically Pin
thatraja26-May-11 17:54
professionalthatraja26-May-11 17:54 
QuestionProblem with horizantaly scrolling need headers movable as datarows Pin
Member 452945219-May-11 3:27
Member 452945219-May-11 3:27 
AnswerRe: Problem with horizantaly scrolling need headers movable as datarows Pin
thatraja29-May-11 5:39
professionalthatraja29-May-11 5:39 
QuestionRegarding Gridview header problem while scrolling Pin
Member 793401119-May-11 3:03
Member 793401119-May-11 3:03 
AnswerRe: Regarding Gridview header problem while scrolling Pin
Pete O'Hanlon19-May-11 3:34
mvePete O'Hanlon19-May-11 3:34 
QuestionException when accessing IHTMLDocument2::frames property Pin
Member 70956418-May-11 20:51
Member 70956418-May-11 20:51 
QuestionIHTML2DOCUMENT2 COM exception Pin
Member 70956418-May-11 18:40
Member 70956418-May-11 18:40 
Reposting in this board as it is more .NET than C# specific


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
AnswerRe: IHTML2DOCUMENT2 COM exception Pin
Shameel20-May-11 0:33
professionalShameel20-May-11 0:33 
QuestionCreate business objects from XML Pin
Jean-Louis Leroy17-May-11 23:24
Jean-Louis Leroy17-May-11 23:24 
QuestionInstalling .NET 3.5 SP1 issue Pin
Bernhard Hiller17-May-11 22:03
Bernhard Hiller17-May-11 22:03 
Questioncontrol z-order without z-index? Pin
Defender-NF17-May-11 1:58
Defender-NF17-May-11 1:58 
AnswerRe: control z-order without z-index? Pin
Ian Shlasko17-May-11 3:38
Ian Shlasko17-May-11 3:38 
GeneralRe: control z-order without z-index? Pin
Defender-NF17-May-11 21:41
Defender-NF17-May-11 21:41 
Questionajax Pin
chandan maurya15-May-11 8:21
chandan maurya15-May-11 8:21 
AnswerRe: ajax Pin
Pete O'Hanlon15-May-11 9:07
mvePete O'Hanlon15-May-11 9:07 
GeneralRe: ajax Pin
AspDotNetDev15-May-11 9:13
protectorAspDotNetDev15-May-11 9:13 
GeneralRe: ajax Pin
Pete O'Hanlon15-May-11 9:18
mvePete O'Hanlon15-May-11 9:18 
AnswerRe: ajax Pin
Abhinav S17-May-11 20:19
Abhinav S17-May-11 20:19 
AnswerRe: ajax Pin
rp_suman2-Jun-11 1:37
rp_suman2-Jun-11 1:37 
Question.Net Framework 1.1 not Installing in Windows Server 2003 Pin
Robymon11-May-11 4:22
Robymon11-May-11 4:22 
AnswerRe: .Net Framework 1.1 not Installing in Windows Server 2003 Pin
Dave Kreskowiak11-May-11 4:30
mveDave Kreskowiak11-May-11 4:30 
GeneralRe: .Net Framework 1.1 not Installing in Windows Server 2003 Pin
Robymon11-May-11 4:37
Robymon11-May-11 4:37 
GeneralRe: .Net Framework 1.1 not Installing in Windows Server 2003 Pin
Dave Kreskowiak11-May-11 4:43
mveDave Kreskowiak11-May-11 4:43 
GeneralRe: .Net Framework 1.1 not Installing in Windows Server 2003 Pin
Robymon11-May-11 21:17
Robymon11-May-11 21:17 

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.