Friday, March 18, 2011

Object tag not recognized inside form tag

Problem: When developing a page in ASP.NET, an object tag (<object>) is not recognized when it is placed in an HTML form tag (<form>).

e.g.
<html>
<head>
   <script type="text/javascript" language="javascript">
    function readScript()
    {
        Card.Connect();
    }
   </script>
</head>


 <body color=white>
    <form name="frmRead" id="frmRead">
        <object id="Card" name="Card" classid="abcDll.dll#abcDll.Card" style="display:none" ></object>
        <input type=button value="Read Card" onClick="readScript();"></td>
    </form>
 </body>
</html>

Solution: Inside the <form> tag, <object> element is out of scope. Instead of directly calling the id of the object, get the id using javascript.
function readScript()
    {
        var cardObj = document.getElementById("Card");
        cardObj.Connect();
    }

Special thanks to StackOverFlow :D
Share:

Wednesday, March 16, 2011

Cannot Run Web Application

Problem: ASP.NET web application can not be run.
Error: WebDev.WebServer.exe has encountered a user-defined breakpoint.


Solution:
The web application you are developing is using Visual Studio development server with dynamic ports. At the same time, you have the same or another web created and running under the same port in IIS.
1. Either stop the IIS for the web which is using the same port as the web application you are going to run under visual studio development server.
2. Or, change the port number of the web application running under visual studio development server. To do this, click on the website, then change the port number in the Properties Window.

Share:

Running ActiveXObject from Javascript

Problem: Can't run ActiveXObject from Javascript
Error: System.Security.Permissions.SecurityPermission

This error occurs when you are trying to run ActiveXObject / dll using Javascript.


Solution:
A. Setting the security for the internet browser, i.e. Internet Explorer
1. Using Internet Explorer, set the security to low: Goto menu Tools -> Internet Options.
2. Goto tab Security.
* Under Internet zone, set security level to Low. Click Custom level button, in ActiveX controls and plug-ins section, Enable Script ActiveX controls marked safe for scripting*, then click OK.



* Under Local intranet zone, click Custom level button, enable things under ActiveX controls and plug-ins section, and the most important one, Enable Script ActiveX controls marked safe for scripting*, then click OK.



B. Setting .Net Framework 2 Configuration
1. Make sure you have .Net Framework 2 SDK installed on your computer. You may want to install it if you have not had it installed on your computer.
2. Goto control panel -> Administrative Tools -> open Microsoft .NET Framework 2.0 Configuration.
3. On the Tasks, click Configure Code Access Security Policy -> Adjust Zone Security -> Make changes to this computer, and Next. Set My computer & Local Intranet to Full trust, then Next -> Finish.




Restart the Internet Explorer, then try running the Web page again.

PS: While it is not recommended to run untrusted ActiveX Object, because it may cause security leak; this is a workaround to solve the problem in case it is necessary to run the ActiveX Object on client side.
Share:

You may be intersted in

Related Posts

Updating Table Containing Xml Column via LinkedServer

If you are trying to update a table containing XML column via Linked Server in SQL Server, and you are not able to, you are not alone. There...

About Me

My photo
Is an ordinary man, with a little knowledge to share and high dreams to achieve. I'd be glad if I can help others, 'coz the only thing for the triumph of evil is for a good man to do nothing.

About Blog

You can find a lot of debugging and deploying problems while developing applications in .NET and Visual Basic here. There are also some querying tips in SQL and typical source codes which might be useful shared here.

Popular Posts

Blogroll

Followers

Leave a Message