Posts

Showing posts from May, 2011

Donate

JQuery Calculator Example In ASP.NET Web Forms

Image
The image above is a jquery/javascript calculator developed in ASP.NET 4.0 web template. Here's the functions. I'wont be posting all codes since it will took up space in my post. I'll just post the sqrt() and a number scripts. The ASPX markup uses plain css for centering and aligning the buttons and html controls. No asp.net server controls are involved. For the jquery processing, im using the id selector. /* show zero to textbox on page load */ $( "#txtCalc" ).ready( function () { $( "#txtCalc" ).val( "0" ); }); //square root $( "#btnSqrt" ).click( function () { var text = $( "#txtCalc" ).val(); //if invalid input,do not execute codes below if (text.search( "Invalid" ) != -1) { return ; } if (text.length == 1) { if (text == "0" ) { return ; }

Random Class In C#.NET Not Generating Proper X And Y Coordinates

I am creating a snippet to change x and y coordinates upon runtime. However,not as i expected,the generated random numbers does not meet my requirements. Here is the C# snippet: switch (odd_eve) { case 0: Random rand = new Random(); count = rand.Next(0, 300); break ; case 1: Random rand1 = new Random(); count = rand1.Next(310, 600); break ; default : } Based from the code above,the random generates a slanting x and y coordinates. The solution i come up came from the idea of a fellow developer to declare one Random object in one class. Random rand = new Random(); //declared as global variable //function snippet switch (odd_eve) { case 0: count = rand.Next(0, 300); break ; case 1: count = rand.Next(310, 600); break ; default : } Works like a charm!!!

How To Debug JavaScript Code In Visual Studio 2008 Or Visual Studio 2010

Here are the simple steps to debug js code in your aspx markup. 1. Open Visual Studio 2008/2010 2. Click Tools then options 3. Expand debugging node then click checkboxes Manages,Native,Script. 4. In your web.config file,make sure to set compilation debug to true. <compilation debug= "true" > <assemblies> <add assembly= "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly= "System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly= "System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> <add assembly= "System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> </assemblies> </compilation> 5. Choo

Donate