Wednesday, 13 June 2012


·         When we use try and catch in .NET or PHP? 

The use of try and catch is to minimize the errors presented to the user and having them handled in a proper fashion by the developer.
Try is a section in which we put code that may cause an error. 
Catch will only be run if there are problems with the code being executed in try.
Finally allow the developer to clean up any code that is left open or hanging after an error occurs or execute even if there is no errors in the code,   
Try{  somecode(); }
Catch(e){  alert(e.message); }
Finally{ alert(‘Thank you’); }

Thursday, 22 March 2012

Problem: Can change Global Resource in ASP.NET?

Impact: When you change languages in Tools-> Options isn't working?

Solution: First of all you have to create App_Global Resource for defining your key after that you have to add Culture="auto" UICulture="auto" in directive control.

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="GlobalResourceExample.aspx.cs"
 Inherits="_Default" Culture="auto" UICulture="auto" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">

<asp:Label ID="lblFirstName" runat="server" Text="<%$ Resources: myResource, LabelFirstName%>" /><br />

<asp:TextBox ID="txtFirstName" runat="server" />
<br />
<asp:Button ID="btn" runat="server" Text="<%$ Resources: myResource, LabelFirstName%>" onClick="subSubmit" />
<br />
<asp:Label ID="lblOut" runat="server" />

</asp:Content>



·   Problem: How can use animation in JavaScript?
 
    Solution: jQuery is a cross-browser javascript library. The syntax provided is to allow easier use of functions and events and provides simple to create animations, handle events and develop AJAX applications.

·    <script type="application/javascript" language="javascript" src="jquery-1.7.1.min.js" ></script>add in header in JavaScript
·        
 Effects: Function show(){$(“#id_name”).show();} .hide(); .slidetoggle(); .fadein(); .fadeout(); .hide(1000); .html(‘content’);

  We will refer to all calls to the jQuery library via the ($) dollar sign.
Selectors: is the term given to the specific tag requested to perform specific actions.  Like: $(“p:first”) 

 Events: $(document).ready(function(e) {   alert("Welcome to my HTML file! "); });
  Several events: .blur(), .change(), .onclick(), .focus(), .onmouseover(), .onkeydown(), .scroll()

  $(“body”).text(“This is new text”) = document.write() function in javascript in HTML page
Problem: How can minimize the errors presented to the user in JavaScript?
Impact: User can see unfriendly error in your website!
Solution:
·     The use of try and catch is to minimize the errors presented to the user and having them handled in a proper fashion by the developer.
  • Try is a section in which we put code that may cause an error. 
  • Catch will only be run if there are problems with the code being executed in try.
  • Finally allow the developer to clean up any code that is left open or hanging after an error occurs or execute even if there is no errors in the code,   
  Try{  somecode(); }
  Catch(e){  alert(e.message); }
  Finally{ alert(‘Thank you’); }
Problem: When have we use IF STATEMENT and when have we use SWITCH STATEMENT?
Solution:

·         If statement: executes a set of commands if the condition is true.
  if ( condition ) { statement; }
 else if ( condition ) { statement; }
  else { statement; }
·        
·         Switch statement: allows a program to evaluate an expression and attempt to match it to a case label.
  Switch ( expression )
  {   Case label1: Statements; Break;
        Case label2: Statements; Break;
        Default:       Statements;  Break; }