Feeds:
Posts
Comments

Hi Friends,

 

You can make asynchronous call of Web service using Javascript

 

The webservice behavior is encapsulated in HTC file.

Therefore before we begin first download this webservice.htc file and copy it into a folder of our webproject.

 

You can download this file from

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/behaviors/library/webservice/default.asp

 

Now your code should be like this

 

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml&#8221; >

<head>

    <title>Untitled Page</title>

</head>

 

<body id=”webServiceCallerBody” onload=”loadService()” style=”behavior:url(webservice.htc);font-size:18″>

<script language=”JavaScript” type=”text/javascript”>

 

function loadService()

 {

webServiceCallerBody.onserviceavailable = enableServiceCall;  //Used for the synchronous call.

webServiceCallerBody.useService(http://localhost:1500/TESTProject.WebService/Service.asmx?wsdl&#8221;,“JS”);

}

 

function callAsynch()

{

      iCallID = webServiceCallerBody.JS.callService(ResponseManipulation, “Function Name”,Parameter1, Parameter2, .. , PareameterN);

}

 

function ResponseManipulation(Response)

 {

  if (!res.error) {

    alert(“Webservice call process successfull. Result is “ + Response.value);

  }

  else {

    alert(“Unsuccessful call. Error is “ + Response.errorDetail.string);

  }

}

Hi Friends,Here is example how to integrate your application with Paypal using Standard Checkout option.But before some steps needed for developer you can ignore first two steps if you have paypal account. Steps are   

  1. First create your one developer account in paypal https://developer.paypal.com/ 
  2. Now choose Test Accounts link and create one test account.

        Note: While creating test account choose Seller radio button. 

  1. Now in sample page write

<input type=”hidden” name=”cmd” value=”_xclick” />

<input type=”hidden” name=”business” value=”Your Test Account Email ID” />

<input type=”hidden” name=”item_name” value=”Item Name” />

<input type=”hidden” name=”currency_code” value=”USD” />

<input type=”hidden” name=”no_shipping” value=”USD” />

<input type=”hidden” name=”return” value=”Return URL” />

<input type=”hidden” name=”cancel_return” value=”Cancel URL” />

<input type=”hidden” name=”rm” value=”2″ />

<input type=”hidden” name=”amount” value=”2.50″ />     

<input type=”hidden” name=”email” value=”Email ID” />     

<input type=”hidden” name=”first_name” value=”Benazir” />     

<input type=”hidden” name=”last_name” value=”Mandli” />     

<input type=”hidden” name=”address1″ value=”Address 1 “ />     

<input type=”hidden” name=”address2″ value=”Address 2″ />     

<input type=”hidden” name=”iscountryspecified” value=”Yes” />     

<input type=”hidden” name=”country” value=”Country” />     

<input type=”hidden” name=”state” value=”State “ />     

<input type=”hidden” name=”city” value=”City “ />     

<input type=”hidden” name=”zip” value=”Zip” />     

<input type=”hidden” name=”night_phone_a” value=”Phone” />

<input type=”hidden” name=”address_override” value=”0″ />     

<asp:Button ID=”btnPay” runat=”server” Text=”Pay using Paypal” />  

  1. write the script

 <script language=”javascript” type=”text/javascript”>     

function SetUserDetail()

{         //LIVE

//document.form1.action =  https://www.paypal.com/cgi-bin/websc&#8217;;                 //TEST  

      document.form1.action =  https://www.sandbox.paypal.com/cgi-bin/webscr&#8217;;        document.form1.submit();        

}      </script> 

  1. and on page load write this

  protected void Page_Load(object sender, EventArgs e)    {            this.btnPay.Attributes.Add(“onclick”, “SetUserDetail()”);

 }

Hi

 Here some steps to connect Firebird Database with Dotnet Framework.

  • First Check Firebird installed on your local pc or Server ? If no, Install Firebird 2.0
  • To connect Firebird with Dotnet, we need Firebird .Net Data provider dll, You can download same from  

           http://prdownloads.sourceforge.net/firebird/FirebirdClient-2.0.1.exe?download

  • In your project, add this dll as reference.
  • In web.config write the connection string for Firebird. It is

     <add key=”connectionstring” value=”Driver={ODBC Driver (*.fdb)};   Database=localhost:C:\test1.fdb;Uid=SYSDBA;DataSource=localhost; Password=masterkey;”/>

  • Now in your page, Inport namespace like  using FirebirdSql.Data.Firebird;
  • Write given code

       FbConnection fbConn = new FbConnection(ConfigurationManager.AppSettings [“connectionstring”].ToString());

                   fbConn.Open();        

      Response.Write(fbConn.State.ToString());

    Fade Effects With Javascript
    ========================

    Script
    ——-

    <script language=”javascript” type=”text/javascript”>

    var TimeToFade = 1000.0;

    function fade(eid)
    {
    var element = document.getElementById(eid);
    if(element == null)
    return;

    if(element.FadeState == null)
    {
    if(element.style.opacity == null
    || element.style.opacity == ”
    || element.style.opacity == ‘1’)
    {
    element.FadeState = 2;
    }
    else
    {
    element.FadeState = -2;
    }
    }

    if(element.FadeState == 1 || element.FadeState == -1)
    {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade – element.FadeTimeLeft;
    }
    else
    {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout(“animateFade(” + new Date().getTime()
    + “,'” + eid + “‘)”, 33);
    }
    }

    function animateFade(lastTick, eid)
    {
    var curTick = new Date().getTime();
    var elapsedTicks = curTick – lastTick;

    var element = document.getElementById(eid);

    if(element.FadeTimeLeft <= elapsedTicks)
    {
    element.style.opacity = element.FadeState == 1 ? ‘1’ : ‘0’;
    element.style.filter = ‘alpha(opacity = ‘
    + (element.FadeState == 1 ? ‘100’ : ‘0’) + ‘)’;
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
    }

    element.FadeTimeLeft -= elapsedTicks;
    var newOpVal = element.FadeTimeLeft/TimeToFade;
    if(element.FadeState == 1)
    newOpVal = 1 – newOpVal;

    element.style.opacity = newOpVal;
    element.style.filter =
    ‘alpha(opacity = ‘ + (newOpVal*100) + ‘)’;

    setTimeout(“animateFade(” + curTick
    + “,'” + eid + “‘)”, 33);
    }

    </script>

    </HEAD>

    How to Use
    —————
    You can use this JavsScript this way.
    Suppose, Your HTML layout is like this :

    <BODY>
    <div id=”fadeBlock” style=”background-color:Lime;width:250px;
    height:65px;text-align:center;”>
    <br />
    I’m Some Text
    </div>
    <br />
    <br />
    <input type=”button” onclick=”fade(‘fadeBlock’);” value=”Go” />

    </BODY>
    </HTML>

    What are the OOPS concepts?

    1) Encapsulation: It is the mechanism that binds together code and
    data in manipulates, and keeps both safe from outside interference and
    misuse. In short it isolates a particular code and data from all other
    codes and data. A well-defined interface controls the access to that
    particular code and data.

    2) Inheritance: It is the process by which one object acquires the
    properties of another object. This supports the hierarchical
    classification. Without the use of hierarchies, each object would need
    to define all its characteristics explicitly. However, by use of
    inheritance, an object need only define those qualities that make it
    unique within its class. It can inherit its general attributes from
    its parent. A new sub-class inherits all of the attributes of all of
    its ancestors.

    3) Polymorphism: It is a feature that allows one interface to be used
    for general class of actions. The specific action is determined by the
    exact nature of the situation. In general polymorphism means “one
    interface, multiple methods”, This means that it is possible to design
    a generic interface to a group of related activities. This helps
    reduce complexity by allowing the same interface to be used to specify
    a general class of action. It is the compiler’s job to select the
    specific action (that is, method) as it applies to each situation.

    What is the difference between a Struct and a Class?

    The struct type is suitable for representing lightweight objects such
    as Point, Rectangle, and Color. Although it is possible to represent a
    point as a class, a struct is more efficient in some scenarios. For
    example, if you declare an array of 1000 Point objects, you will
    allocate additional memory for referencing each object. In this case,
    the struct is less expensive.
    When you create a struct object using the new operator, it gets
    created and the appropriate constructor is called. Unlike classes,
    structs can be instantiated without using the new operator. If you do
    not use new, the fields will remain unassigned and the object cannot
    be used until all of the fields are initialized.
    It is an error to declare a default (parameterless) constructor for a
    struct. A default constructor is always provided to initialize the
    struct members to their default values.
    It is an error to initialize an instance field in a struct.
    There is no inheritance for structs as there is for classes. A struct
    cannot inherit from another struct or class, and it cannot be the base
    of a class. Structs, however, inherit from the base class Object. A
    struct can implement interfaces, and it does that exactly as classes
    do.
    A struct is a value type, while a class is a reference type.

    Value type & reference types difference? Example from .NET. Integer
    & struct are value types or reference types in .NET?

    Most programming languages provide built-in data types, such as
    integers and floating-point numbers, that are copied when they are
    passed as arguments (that is, they are passed by value). In the .NET
    Framework, these are called value types. The runtime supports two
    kinds of value types:
    Built-in value types
    The .NET Framework defines built-in value types, such as System.Int32
    and System.Boolean, which correspond and are identical to primitive
    data types used by programming languages.
    User-defined value types
    Your language will provide ways to define your own value types, which
    derive from System.ValueType. If you want to define a type
    representing a value that is small, such as a complex number (using
    two floating-point numbers), you might choose to define it as a value
    type because you can pass the value type efficiently by value. If the
    type you are defining would be more efficiently passed by reference,
    you should define it as a class instead.
    Variables of reference types, referred to as objects, store references
    to the actual data. This following are the reference types:
    class
    interface
    delegate
    This following are the built-in reference types:
    object
    string

    What is Method Overriding? How to override a function in C#?

    Use the override modifier to modify a method, a property, an indexer,
    or an event. An override method provides a new implementation of a
    member inherited from a base class. The method overridden by an
    override declaration is known as the overridden base method. The
    overridden base method must have the same signature as the override
    method.
    You cannot override a non-virtual or static method. The overridden
    base method must be virtual, abstract, or override.

    Can we call a base class method without creating instance?

    Its possible If its a static method.
    Its possible by inheriting from that class also.
    Its possible from derived classes using base keyword.

    In which cases you use override and new base?

    Use the new modifier to explicitly hide a member inherited from a base
    class. To hide an inherited member, declare it in the derived class
    using the same name, and modify it with the new modifier.

    What are Sealed Classes in C#?

    The sealed modifier is used to prevent derivation from a class. A
    compile-time error occurs if a sealed class is specified as the base
    class of another class. (A sealed class cannot also be an abstract
    class)

    UDDI
    (Universal Description, Discovery and Integration)

    WSDL
    (Web Services Discription Language)

    Web Service (Definition)

    – The W3C defines a Web service[1] as a software system designed to support interoperable machine-to-machine interaction over a network.

    – A Web Service is a software component that is described via WSDL and is capable of being accessed via standard network protocols such as but not limited to SOAP over HTTP.

    SOAP (Definition)

    – SOAP is a standard for exchanging XML-based messages over a computer network, normally using HTTP. SOAP forms the foundation layer of the web services stack, providing a basic messaging framework that more abstract layers can build on.

    .Net code Compilation and Execution

    * Source code is converted to Microsoft Intermediate Language and an assembly is created.
    * Upon execution of a .NET assembly, its MSIL is passed through the Common Language Runtime’s JIT compiler to generate native code. (NGEN compilation eliminates this step at run time.)
    * The native code is executed by the computer’s processor.

    What is XML ?

    – XML (Extensible Markup Language) is a W3C initiative that allows information and services to be encoded with meaningful structure and semantics that computers and humans can understand. XML is great for information exchange, and can easily be extended to include user-specified and industry-specified tags.
    – XML is a markup language for documents containing structured information.

    What is UML ?

    UML is a general-purpose modeling language that includes a standardized graphical notation used to create an abstract model of a system.

    Use Regular Expression by JavaScript
    ===============================

    1 function validateEmail()2 {3 // Value to Validate. Ex. Your EMail Address TextBox4 var EMailID = document.getElementById(‘txtEMail’).value;56 // Here, we set the Expression to Validate the Value for EMail Address.7 var EMailValidate = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;89 // Test the Validator.10 if( EMailValidate.test(EMailID))11 {12 alert(‘Right Email Address.’);13 }14 else15 {16 alert(‘Wrong Email Address.’);17 }18

    Use ICallbackEventHandler in Asp.Net 2.0
    ==================================

    For Example, you have page Layout is like this :

    <META NAME=”Generator” CONTENT=”EditPlus”>
    <META NAME=”Author” CONTENT=””>
    <META NAME=”Keywords” CONTENT=””>
    <META NAME=”Description” CONTENT=””>
    </HEAD>

    <BODY>
    <div id=”divResult” runat=”server”>
    </div>
    <br/>
    <input type=”button” value=”Text ICallBack” onclick=”return GetPop()” />

    </BODY>
    </HTML>

    Steps to Implement ICallbackEventHanler:
    ————————————————-

    1. First define string variable in Common section of your code behind (.cs) file.

    string _CallBackString;

    2. Inherit ICallbackEventHandler in your page.

    public partial class Customize : System.Web.UI.Page, ICallbackEventHandler

    3. Now, write this code in your Page_Load() Event

    ClientScriptManager cs = Page.ClientScript;

    string cbRef = cs.GetCallbackEventReference(this, “arg”, “ShowPop”, “context”);
    string cbScript = “function CallPopBack(arg, context){” + cbRef + “;}”;
    cs.RegisterClientScriptBlock(this.GetType(), “CallPopBack”, cbScript, true);

    4. Now, Write some javascript code, in your design section of your page.

    function GetPop()
    {
    var justExample = ‘Hi..All..’;

    CallPopBack(justExample)
    }
    function ShowPop(result, context)
    {

    var strResult = new String();
    strResult = result;

    alert(result);
    }

    4. Now, In your code behind (.cs) file, write code for your EventHandle Method.

    public string GetCallbackResult()
    {
    return _CallBackString;
    }

    public void RaiseCallbackEvent(string eventArgument)
    {
    _CallBackString = eventArgument + ” ” + DateTime.Now.ToShortTimeString();
    }

    5. Run the page and test this page.

    Hope you will like it.

    Javascript to Allow only numbers in TextBox
    ======================================

    <script language=”javascript” type=”text/javascript”>

    function CheckKeyCode(e)
    {
    if (navigator.appName == “Microsoft Internet Explorer”)
    {
    if((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode == 8))
    {
    return true;
    }
    else
    {
    return false;
    }
    }
    else
    {
    if ((e.charCode >= 48 && e.charCode <= 57) || (e.charCode == 0))
    {
    return true;
    }
    else
    {
    return false;
    }
    }
    }

    </script>

    // Add this code in your GridView control’s RowDataBound Event.

    ((TextBox)e.Row.FindControl(“txtDispOrder”)).Attributes.Add(“onkeypress”, “javascript:return CheckKeyCode(event);”);

     

    In Enterprise Library 3.0, the Data Access Application Block now supports batch updates functionality. This helps us to eliminate number of roundtrips with the Database.  

     The syntax for the update dataset is as follows 

    Database.UpdateDataSet(DataSet dataSet, string tableName,
        DbCommand insertCommand, DbCommand updateCommand,
        DbCommand deleteCommand, UpdateBehavior updateBehavior,
       
    int? updateBatchSize);

    Consider one table named Student as follows 

    Studentid , Name, Address, City 

    We will update address and city of all students with one roundtrip.  

    // First Create object for default Database   
    
    Database database = DatabaseFactory.CreateDatabase();       
    
    // Fetch all Student data in a dataset    
    
    string selectSql = " SELECT * FROM Student";   
    
    DataSet dsStudent = database.ExecuteDataSet(CommandType.Text, selectSql); 
    
    // modify Address and city   
    foreach (DataRow dr in dsStudent.Tables[0].Rows)     
    
    {     
    
    dr["Address"] += "New Address";     
    
    dr["City"] += " New City";     
    
    }     
    
    // Create Update Command  
    string updateSql = "UPDATE Student SET Address=@Address, City = @City WHERE StudentId = @StudentId";        
    
    DbCommand cmdUpdate = database.GetSqlStringCommand(updateSql);    
    
    database.AddInParameter(cmdUpdate, "StudentId",DbType.Int32, "StudentId", DataRowVersion.Current);    
    
    database.AddInParameter(cmdUpdate, "Address",DbType.String, "Address", DataRowVersion.Current);    
    
    database.AddInParameter(cmdUpdate, "City",DbType.String, "City", DataRowVersion.Current);    
    
    // Execute Batch Update 
     // provide NULL for other commands    
    
    database.UpdateDataSet(dsStudent, "TableName", null,cmdUpdate, null, UpdateBehavior.Transactional, 0 );       
    
    
    - Benazir

    Convert a string to Proper Case
    ===========================

    // Use this Namespace
    using System.Globalization;

    // Code
    string myString = “thIS is tHE sAmple tExt to shoW tHIs examPle !!”;

    TextInfo TI = new CultureInfo(“en-US”,false).TextInfo;

    Response.Write (TI.ToTitleCase( myString ));