Click here to Skip to main content
15,886,778 members
Articles / Web Development / ASP.NET

An Easy Way to Implement ASP.NET Callback

Rate me:
Please Sign up or sign in to vote.
4.31/5 (5 votes)
3 Sep 2010CPOL5 min read 44.1K   689   17  
Implementing callback inside User Control, choosing between client callback and Ajax framework
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="SimplePage_CallBack.aspx.vb" Inherits="_Default" %>
<%@ Register src="CallBackHandler.ascx" tagname="CallBackHandler" tagprefix="uc1" %>

<!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></title>
    
    <script language="javascript" type="text/javascript">
<!--

        function btnSubmit_onclick() {

            var param1, param2, param3;
            param1 = document.getElementById('txtParam1').value;
            param2 = document.getElementById('txtParam2').value;
            param3 = document.getElementById('txtParam3').value;
            asyncall(param1 + '$$' + param2 + '$$' + param3, 1, 'divResult');
        }

        function btnSubmit2_onclick() {

            var param1, param2;
            param1 = document.getElementById('txtParam1_Sample2').value;
            param2 = document.getElementById('txtParam2_Sample2').value;
            asyncall(param1 + '$$' + param2, 2, 'divResult2');
        }


// -->
    </script>
  
    <style type="text/css">
        .style1
        {
            height: 24px;
            text-align: center;
        }
        .style2
        {
            height: 27px;
        }
        .style3
        {
            height: 21px;
            text-align: center;
        }
    </style>
  
</head>
<body>
    <form id="form1" runat="server">
    <uc1:CallBackHandler ID="CallBackHandler1" runat="server" />
    
    <table align="left" style= "width: 368px;"  dir="ltr">
        <tr>
            <td style= "font-weight: 700; text-align: center; text-decoration: underline; color: #FFFF00; background-color: #CC0000;" 
                class="style2" colspan="2">
               sample 1 :</td>
        </tr>
        <tr>
            <td class="style1">
               param 1 :</td>
            <td>
            <asp:TextBox ID="txtParam1" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style1">
              param 2 :</td>
            <td>
            <asp:TextBox ID="txtParam2" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style1">
               param 3 :</td>
            <td>
            <asp:TextBox ID="txtParam3" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style1">
                </td>
            <td>
            <input id="btnSubmit" type="button" value="submit" style="width:100px" onclick="return btnSubmit_onclick()" /></td>
        </tr>
        <tr>
            <td class="style1">
              Result : </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style1" colspan="2">
        <div id="divResult" style="float:left;border: 1px solid #DDDDDD;width:348px; height:70px;text-align:left">
        </div>
            </td>
        </tr>
    </table>
    
    <table align="left" style= "width: 364px;"  dir="ltr">
        <tr>
            <td style= "font-weight: 700; text-align: center; text-decoration: underline; color: #FFFF00; background-color: #CC0000;" 
                class="style2" colspan="2">
               sample 2 :</td>
        </tr>
        <tr>
            <td class="style1">
               param 1 :</td>
            <td>
            <asp:TextBox ID="txtParam1_Sample2" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style1">
               param 2 :</td>
            <td>
                <asp:TextBox ID="txtParam2_Sample2" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style1">
                &nbsp;</td>
            <td>
            <input id="btnSubmit2" type="button" value="submit" style="width:100px" 
                   onclick="return btnSubmit2_onclick()" /></td>
        </tr>
        <tr>
            <td class="style1">
              Result : </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style3" colspan="2">
        <div id="divResult2" style="float:left;border: 1px solid #DDDDDD;width:348px; height:70px;text-align:left">
        </div>
            </td>
        </tr>
    </table>


    </form>
    
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer asemantek.ir
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions