We are using RegisterClientScriptBlock to insert our dll named "myPrintUtility" into the page in question and then try to access via javascript (shown below) and we are getting what appears to be a generic object returned sometimes....
when we get this generic object, then as soon as we try to call a routine (like objPrint.PrinterCount()) we get an error stating, "Microsoft.JScript runtime error: Object doesn't support this property or method. Again this works on 95-99% of our client machines,
but doesn't work on the remaining. We also have one development machine that suffers from this issue while everyone else's works just fine. Please help!
<div class="bbcode_container">
function _objPrint()
{
objPrint = document.getElementById("myPrintUtility");
}
function LoadPrinters()
{
if (objPrint == null)
{
_objPrint();
}
var count = objPrint.PrinterCount();
.
.
.
Here is some additional detail (which to this point has not helped me) which may help:
When I examine objPrint on a machine that works it returns a "value" of ControlAxSourcingSite[MyNamespace.MyClass] and a "type" of DispHTMLObjectElement, but on the DEV machine that does not work it simply shows "Object" under type and "{...}" under value..obviously
it is not seeing the object correctly.
Thanks Song-Tain, I've tried this approach this morning, but I'm not really getting any new/additional information. Maybe I'm using the tools incorrectly? How would this help me hone in on the issue...sorry for being such a newbie.
We are already debugging with VS2010, which I would think would be the "best" way to debug this?
The more I look at this, the more I think this is a security hole...but you (experts) tell me. I've inherited this application from a previous developer who has now left the group. Best I can tell in using RegisterClientScriptBlock you "should" only be
able to register javascript code...is this correct? If so, that is not what we are currently doing...rather we are loading up a .net dll with this call and then callng the .net dll from the javascript. This dll has the ability to do whatever it wants on
the client system (running under the logged on user's rights). This dll is being downloaded in the background (unbeknowst) to the end user and then accessed via the javascript. Javascript is designed to run in a sandbox (behind IE) right? Well this seems
to workaround that and allow full access to the system. Now our dll is not doing anything harmful, rather aiding in some specialized printing...but still...this seems like I could easily get someone to browse to my webpage, get my harmful dll downloaded readily
and then start executing code on the file/folder system...am I wrong? I can't find anyone that is doing what our app is currently doing today...every post/forum/website I've found seem to only be passing (in the script parameter) a string value and this string
is javascript code....we are passing in an object which happens to be a .net dll. Does this make sense?
When the html render completely. Please check the html source code. And I think you could find the related javascript. Any more question, please feel free to reply.
Please mark the replies as answers if they help or unmark if not.
Feedback to us
njh2012
0 Points
9 Posts
Sometimes getElementById returns wrong/generic object
Aug 01, 2012 10:15 PM|LINK
We are using RegisterClientScriptBlock to insert our dll named "myPrintUtility" into the page in question and then try to access via javascript (shown below) and we are getting what appears to be a generic object returned sometimes....
<div class="bbcode_container">when we get this generic object, then as soon as we try to call a routine (like objPrint.PrinterCount()) we get an error stating, "Microsoft.JScript runtime error: Object doesn't support this property or method. Again this works on 95-99% of our client machines, but doesn't work on the remaining. We also have one development machine that suffers from this issue while everyone else's works just fine. Please help!
function _objPrint() { objPrint = document.getElementById("myPrintUtility"); } function LoadPrinters() { if (objPrint == null) { _objPrint(); } var count = objPrint.PrinterCount(); . . .</div>A1ien51
All-Star
29935 Points
5821 Posts
Re: Sometimes getElementById returns wrong/generic object
Aug 02, 2012 03:20 PM|LINK
njh2012
0 Points
9 Posts
Re: Sometimes getElementById returns wrong/generic object
Aug 02, 2012 03:52 PM|LINK
Thanks for the response! We'll double check to make sure..but thinking we have checked this several times.
njh2012
0 Points
9 Posts
Re: Sometimes getElementById returns wrong/generic object
Aug 02, 2012 05:25 PM|LINK
....compared all the settings under custom level between a working DEV machine and one that does not work...no difference.
njh2012
0 Points
9 Posts
Re: Sometimes getElementById returns wrong/generic object
Aug 02, 2012 05:38 PM|LINK
Here is some additional detail (which to this point has not helped me) which may help:
When I examine objPrint on a machine that works it returns a "value" of ControlAxSourcingSite[MyNamespace.MyClass] and a "type" of DispHTMLObjectElement, but on the DEV machine that does not work it simply shows "Object" under type and "{...}" under value..obviously it is not seeing the object correctly.
Song-Tian - ...
All-Star
43705 Points
4304 Posts
Microsoft
Re: Sometimes getElementById returns wrong/generic object
Aug 03, 2012 06:21 AM|LINK
Hi,
I suggest you debugging with IE Developer Tools. Any more question, please feel free to reply.
Feedback to us
Develop and promote your apps in Windows Store
njh2012
0 Points
9 Posts
Re: Sometimes getElementById returns wrong/generic object
Aug 03, 2012 03:11 PM|LINK
Thanks Song-Tain, I've tried this approach this morning, but I'm not really getting any new/additional information. Maybe I'm using the tools incorrectly? How would this help me hone in on the issue...sorry for being such a newbie.
We are already debugging with VS2010, which I would think would be the "best" way to debug this?
njh2012
0 Points
9 Posts
Re: Sometimes getElementById returns wrong/generic object
Aug 03, 2012 11:06 PM|LINK
More background:
The more I look at this, the more I think this is a security hole...but you (experts) tell me. I've inherited this application from a previous developer who has now left the group. Best I can tell in using RegisterClientScriptBlock you "should" only be able to register javascript code...is this correct? If so, that is not what we are currently doing...rather we are loading up a .net dll with this call and then callng the .net dll from the javascript. This dll has the ability to do whatever it wants on the client system (running under the logged on user's rights). This dll is being downloaded in the background (unbeknowst) to the end user and then accessed via the javascript. Javascript is designed to run in a sandbox (behind IE) right? Well this seems to workaround that and allow full access to the system. Now our dll is not doing anything harmful, rather aiding in some specialized printing...but still...this seems like I could easily get someone to browse to my webpage, get my harmful dll downloaded readily and then start executing code on the file/folder system...am I wrong? I can't find anyone that is doing what our app is currently doing today...every post/forum/website I've found seem to only be passing (in the script parameter) a string value and this string is javascript code....we are passing in an object which happens to be a .net dll. Does this make sense?
Song-Tian - ...
All-Star
43705 Points
4304 Posts
Microsoft
Re: Sometimes getElementById returns wrong/generic object
Aug 06, 2012 02:41 AM|LINK
Hi,
When the html render completely. Please check the html source code. And I think you could find the related javascript. Any more question, please feel free to reply.
Feedback to us
Develop and promote your apps in Windows Store
njh2012
0 Points
9 Posts
Re: Sometimes getElementById returns wrong/generic object
Aug 06, 2012 02:50 AM|LINK