Monday, 15 October 2012

Web user control with AJAX

Step by Step procedure for making  the Web User Control with Ajax

Step: 1: - create web user controls with public properties and event at.ascx.cs and switch to design part with (update panel + Grid view + Sql Data Source)
Step: 2: - Through sql data source, bind the user specific data from the database, let’s say we bind tbdept table.
Step: 3: - code behind technique w.r.t design part.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class WebUserControl : System.Web.UI.UserControl
{
   public delegate void abc(object s, EventArgs e);
    public event abc myclick;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public Int32 p_GetDno
    {
        get
        {
            return Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text);

        }
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        myclick(this, e);
    }
}
Step: 4: - Again create one more user control and on the design part drop   grid  View and sql data source in update panel.
Step: 5: - Configure the sql data source and with where clause .(Bind tbemp and in where clause define edno)
Step: 6 - set the coding window w.r.t the design part.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class WebUserControl2 : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public Int32 p_SetDno
    {
        set
        {
            SqlDataSource1.SelectParameters["edno"].DefaultValue = value.ToString();
            GridView1.DataBind();
        }
    }
}

Step: 7: - Create web page (.aspx) and drop the user controls from the solution explorer with script manager
Step: -8: - Now finally we can get the services of AJAX with web user control.

No comments:

Post a Comment

QUICK REVISION of the Informatics Practices Examination

QUICK REVISION of the Informatics Practices Examination Data Types Every value belongs to a specific data type in Python. Data type iden...