Showing posts with label ASP.NET. Show all posts
Showing posts with label ASP.NET. Show all posts

Wednesday, December 14, 2011

ASP.NET Web Forms : Calling Web Service Page Methods Using JQuery

Amazing, this article shows how to call PageMethod without using 'ScriptManager'

http://tugberkugurlu.com/archive/asp-net-web-forms---calling-web-service-page-methods-using-jquery

Thanks Ugurlu

//-----------------------------------------------------------------------------+
// jQuery call AJAX Page Method                                                |
//-----------------------------------------------------------------------------+
function PageMethod(fn, paramArray, successFn, errorFn) {
var pagePath = window.location.pathname;
//-------------------------------------------------------------------------+
// Create list of parameters in the form:                                  |
// {"paramName1":"paramValue1","paramName2":"paramValue2"}                 |
//-------------------------------------------------------------------------+
var paramList = '';
if (paramArray.length > 0) {
for (var i = 0; i < paramArray.length; i += 2) {
            if (paramList.length > 0) paramList += ',';
paramList += '"' + paramArray[i] + '":"' + paramArray[i + 1] + '"';
}
}
paramList = '{' + paramList + '}';
//Call the page method
$.ajax({
type: "POST",
url: pagePath + "/" + fn,
contentType: "application/json; charset=utf-8",
data: paramList,
dataType: "json",
success: successFn,
error: errorFn
});
}

Tuesday, July 8, 2008

Data Access Tutorial in ASP.NET 2.0

quote from site :

Series of tutorials that will explore techniques for implementing these common data access patterns in ASP.NET 2.0. These tutorials are geared to be concise and provide step-by-step instructions with plenty of screen shots to walk you through the process visually. Each tutorial is available in Visual Basic and Visual C# versions and includes a download of the complete code used.

http://www.asp.net/learn/data-access/?lang=cs#intro

Sunday, January 20, 2008

ASP.NET - IronPython

It's now possible to use IronPython in Visual Web Developpement Express Edition 2008.
If you are wondering does it worth to switch to IronPython.
Look at this server side part, and compare it with the traditionals languages used

Server Side:

def Page_Load(sender, e):
pass

def onClickButton1(s,e):
color = result.InnerHtml = TextBox1.Text
result.Style.set_Value("background-color:%s;"%color)

def Menu1_MenuItemClick(s,e):
result.Style.set_Value("background-color:red")
choice = Menu1.SelectedValue
result.InnerHtml = choice


Client Part:

<%@ Page Language="IronPython" CodeFile="Default.aspx.py" Inherits="Microsoft.Web.Scripting.UI.ScriptPage" %>

<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" OnMenuItemClick="Menu1_MenuItemClick">
<Items>
<asp:MenuItem Text="Fichier" Value="Fichier"></asp:MenuItem>
<asp:MenuItem Text="About" Value="About"></asp:MenuItem>
</Items>
</asp:Menu>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="onClickButton1" />
<div id="result" runat="server">
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>