Dec 31, 2011

Easily build powerful client-side AJAX paging, using jQuery

When I suggest that developers consider using web services and a more client-centric approach to solve their UpdatePanel performance problems, the lack of paging is often their first objection.
Conventional ASP.NET wisdom seems to hold that the GridView/UpdatePanel combo is king when asynchronously paging through a data source. If you’ll give me a few minutes of your time, I’d like to challenge that notion!

To read more click on the below link
http://encosia.com/easily-build-powerful-client-side-ajax-paging-using-jquery/

Inline text editing with ASP.NET AJAX

This is a technique that I really like. It’s excellently suited to intranet sites and administrative interfaces, where your users are typically familiar enough with the application to know which text they can click to edit. It’s actually very easy to implement, with a small amount of JavaScript.


to view code click on below link

http://encosia.com/seamless-inline-text-editing-with-aspnet-ajax/

how to pass a JavaScript object to a .NET webservice that expects a parameter of type object.

Introduction

This article shows how to pass a JavaScript object to a .NET webservice that expects a parameter of type object. JSON is an enormously powerful and lightweight way to send data to and from a webservice, however if there are a number of parameters that are needed to be sent to webservice, building a JSON string can be a pain, and having to set your webmethod to expect a matching number of parameters can be equally as painful. This article shows how to build and pass a JavaScript object "Customer" and pass it to a .NET webservice webmethod that is expecting an object of type "Customer".

for more click on below link
http://smartprogrammingspot.blogspot.com/2010/06/javascript-objects-to-net-webmethods.html

Why ASP.NET AJAX UpdatePanels are dangerous

If you’re like me, it’s hard to resist the lure of tossing a half dozen UpdatePanels on every page and reveling in AJAX goodness. The UpdatePanel makes AJAX trivially easy for anyone to implement, even without knowledge of what’s actually going on behind the scenes.
Unfortunately, that very lack of transparency regarding the mechanics of the client/server exchange makes it all too easy to shoot yourself (or your application) in the foot. Let me give you an example that you’re probably familiar with by now, and thoroughly sick of seeing:


for more view below links
http://encosia.com/why-aspnet-ajax-updatepanels-are-dangerous/

Dec 29, 2011

Formula for Create Amount In String in Crystal Report .net





numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :=" ";

Amt := {sp_OfferHeaderReport;1.nMTotalOfferValue};

if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;
if RmVal = 1 then
InWords := InWords + " " + towords(RmVal,0) + " crore"
else
if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crores";
Amt := Amt - Rmval * 10000000;
if Amt > 100000 then RmVal := truncate(Amt/100000);
if Amt = 100000 then RmVal := 1;

if Amt> 100000 then

InWords := InWords + " " + towords(RmVal,0) + " lakhs";
Amt := Amt - Rmval * 100000;
if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);
pAmt := (Amt - truncate(Amt)) * 100;
if pAmt > 0 then
InWords := InWords + " and " + towords(pAmt,0) + " paisa only"
else
InWords := InWords + " only";
UPPERCASE(InWords)

Dec 21, 2011

Sample Web Method

=============================== Aspx Page Source ============================


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>:: Using PageMethods :: </title>
    <style type="text/css">
        #MessagePlaceholder
        {
            background-color: #C0C0C0;
        }
    </style>
</head>
<body>
    <script language="javascript" type="text/javascript">
       // Step 4: Use the PageMethod from code
       function getServerGreeting() {
           $get("MessagePlaceholder").innerHTML =
               "<img alt=\"Please Wait\" src=\"image\\ajaxwait01.gif\" />";
           // NOTE: Instead of using getElementById in the last
           // statement, ASP.AJAX has a shortcut to this method
           // that does the same thing, $get.
           // Call the server method
           PageMethods.GetGreeting(getServerGreeting_Success);
           return false;
       }
       // Step 5: Process the callback
       function getServerGreeting_Success(result) {
           /// <summary>
           /// This is the callback method to handle the
           /// result from the server.
           /// </summary>
           /// <param name="result">The result from the server</param>
           $get("MessagePlaceholder").innerHTML = result;
           $get("<%= Label1.ClientID %>").innerText = 'on Label1 '+ result;
           $get("<%= TextBox1.ClientID %>").value = 'on TextBox1 '+ result;
       }
    </script>
    <form id="form1" runat="server">
        <div style="text-align:center; width:200px;">
            <!-- Step 1: Add a ScriptManager to the page -->
            <!-- Step 2: Set the EnablePageMethods property to true -->
            <asp:scriptmanager id="sm" runat="server" enablepagemethods="true" />
            
            <input type="button" value="Get Message Html Btn" onclick=" return getServerGreeting();" 
                style="width:145px;" /><br />
            <asp:Button ID="Button1" runat="server" Text="Asp Button with Page Method" 
                Width="192px" onclientclick=" return getServerGreeting();" />
            <br />
            <asp:Button ID="Button2" runat="server" 
                Text="Asp Button with without Page Method" onclick="Button2_Click" /><br />
            <asp:Label ID="Label1" runat="server" Text="Label" BackColor="#B6C8ED"></asp:Label>
            <br />
&nbsp;<asp:TextBox ID="TextBox1" runat="server" Width="340px"></asp:TextBox>
            <br />
            <div id="MessagePlaceholder"></div>
        </div>
    </form>
</body>
</html>


=============================== C# Page Code =================================



using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


using System.Web.Services; /// new add for webMethod 
using System.Threading;/// for threading purpose (optional) if 




public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("On PageLoad: " + DateTime.Now.ToLongTimeString());
    }




    [WebMethod]
    public static string GetGreeting()
    {
        // Step 3: Create a static method and decorate it with
        //         the WebMethod attribute
        // In order to slow the method down a bit to illustrate
        // the async call, have the method wait 2 seconds.
        Thread.Sleep(2000); //optional
        // Return the result
        return "Hello PageMethods: "+DateTime.Now.ToLongTimeString();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Write(" On Button Click : " + DateTime.Now.ToLongTimeString());
        TextBox1.Text = " On Button Click : " + DateTime.Now.ToLongTimeString();
        Label1.Text = " On Button Click : " + DateTime.Now.ToLongTimeString();
    }
}




Use Image





useful link
http://blogs.visoftinc.com/2008/09/07/asp-net-ajax-page-methods/


Dec 16, 2011

How to Get Last Day of the week and Month

DECLARE @Date datetime
SET @Date = '2000/02/1'
SELECT DATEADD(dd,-(DATEPART(dw, @Date) - 1),@Date) AS 'First day of the week'
SELECT DATEADD(dd,-(DATEPART(dw, @Date) - 7),@Date) AS 'Last day of the week'
SELECT DAY(DATEADD(d, -DAY(DATEADD(m,1,@Date)),DATEADD(m,1,@Date))) AS 'Last day of the month'

SELECT convert(varchar, DATEADD(d, -DAY(DATEADD(m,1,@Date)),DATEADD(m,1,@Date)), 101) AS 'Last Date of the month'

Insert into oracle table By XML In StoreProcedure

Well, after a bit of looking on Oracle's Metalink, I found some information on
passing XML to stored procedures via varchars or CLOBs. Here are examples of an
insert and of an update:

Create procedure to take in xml as a varchar or a clob:

create or replace procedure InsertXML(xmlDoc IN VARCHAR2, tableName IN
VARCHAR2) is

insCtx DBMS_XMLSave.ctxType;

rows number;

begin

insCtx := DBMS_XMLSave.newContext(tableName); -- get the context handle

rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc); -- this inserts the document

dbms_output.put_line(to_char(rows) || ' rows inserted');

DBMS_XMLSave.closeContext(insCtx); -- this closes the handle

end;

The xml text that is passed must be in the form of:

<?xml version="1.0"?>

<ROWSET>

<ROW num="1">

<EMPID>10</EMPID>

<EMPNAME>Perry Smith</EMPNAME>

<EMPJOB>Manager</EMPJOB>

<EMPSAL>800</EMPSAL>

</ROW>

<ROW num="1">

<EMPID>20</EMPID>

<EMPNAME>John Calvach</EMPNAME>

<EMPJOB>Principal Support Consultant</EMPJOB>

<EMPSAL>900</EMPSAL>

</ROW>
</ROWSET>

Notice that the tags nested in the <ROW> tag are the same as the columns in
any table you would use. I don't know if it is case sensitive or not, but I
build all the xml as uppercase just in case.

This is using the internal Oracle XML parser for PL/SQL.

The update procedure is a bit different, because you have to tell it which
item is the primary key This procedure would update the empleados table which
has a primary key of empid:

create or replace procedure UpdateEmpleados ( xmlDoc IN VARCHAR2) is

updCtx DBMS_XMLSave.ctxType;

rows number;

begin

updCtx := DBMS_XMLSave.newContext('empleados'); -- get the context

DBMS_XMLSave.clearUpdateColumnList(updCtx); -- clear the update settings..

DBMS_XMLSave.setKeyColumn(updCtx,'EMPID'); -- set EMPNO as key column

rows := DBMS_XMLSave.updateXML(updCtx,xmlDoc); -- update the table.

dbms_output.put_line(to_char(rows) || ' rows updated');

DBMS_XMLSave.closeContext(updCtx); -- close the context..!

end;

And that's it! It seems to work quite well, and now I don't have to use the
<cftransaction> tag and let the database handle all rollbacks, etc.

Thanks for all the help on this!

What is the use of n-tier architecture and 3-tier architecture?

how to implement 3-tier architecture in asp.net using c#. 3-Tier architecture is also called layered architecture. Some people called it ...