Breaking News

Editors Picks

Wednesday, March 23, 2011

Implementing ICallBackEventHandler in ASP.Net

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ICallBackEventHandlerSample._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 runat="server">
    <title>ICallbackEventHandlertitle>

    <script language="javascript" type="text/javascript">
        function GetResult(returnValue, context) {
            document.getElementById("txtDateTime").value = returnValue;
        }
        function Request() {
            CallServer();
            return false;
        }
    script>

head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="txtDateTime" runat="server" Text="">
    asp:TextBox>
    <asp:Button ID="btnDateTime" OnClientClick="return Request()" runat="server"
        Text="Get Server Date Time" />
    form>
body>
html>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
 
namespace ICallBackEventHandlerSample
{
    public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ClientScriptManager scriptManager = Page.ClientScript; 
            String cbReference = scriptManager.GetCallbackEventReference
            (this, "returnValue", "GetResult", "context");
            String callbackScript = "function CallServer(returnValue, context)
            {" + cbReference + "; }";
            scriptManager.RegisterClientScriptBlock(this.GetType(),
            "CallServer", callbackScript, true);
          
       }       
        private string returnValue;
        public string GetCallbackResult()
        {
            return returnValue;
        }
 
        public void RaiseCallbackEvent(string eventArgument)
        {
            returnValue = DateTime.Now.ToString();
        }      
    }
}

Read more ...

Friday, March 11, 2011

Merging Two DataTables in C#

 Merging Two DataTables in C#

private void MergeDataTable()
        {

            DataTable dtOne = new DataTable("FirstTable");

            dtOne.Columns.Add("MyColumn");

            DataTable dtTwo = new DataTable("SecondTable");

            dtTwo.Columns.Add("MyColumn");

            for (int i = 1; i <= 10; i++)
            {

                DataRow row = dtOne.NewRow();

                row["MyColumn"] = "Data" + i;

                dtOne.Rows.Add(row);

            }

            for (int i = 11; i <= 20; i++)
            {

                DataRow row = dtTwo.NewRow();

                row["MyColumn"] = "Data" + i;

                dtTwo.Rows.Add(row);

            }

            DataSet ds = new DataSet();

            ds.Tables.Add(dtOne);

            ds.Merge(dtTwo);

            DataGrid1.DataSource = ds;

            DataGrid1.DataBind();

        }
Read more ...

Monday, March 7, 2011

sharing your data on facebook using asp.net


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm12.aspx.cs" Inherits="WebApplication1.WebForm12" %>

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 Pagetitle>
head>
<body>
    <form id="form1" runat="server">
    <div>
    <script type="text/javascript">

    function fbs_click() {

        u=location.href;

        t=document.title;

        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');

        return false;

    }

   

script>

<a href="#" onclick="return fbs_click();" target="_blank" class="shareCtrlLink"><img src="export_icons/facebook.png" border="0" alt="Share on Facebook" align="middle" />Facebooka>

    div>
    form>
body>
html>

Read more ...

Contact Us

Name

Email *

Message *