NEDEN AJAX? ÖRNEK PROGRAM KODLARI

f-Update Progress Kontrolü:

HTML KODU:

<form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server" />

        <div>

            <asp:UpdatePanel ID="UpdatePanel1" runat="server">

                <ContentTemplate>

                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />

                    <br />

                    <br />

                    <asp:Label ID="Label1" runat="server"></asp:Label>

                </ContentTemplate>

            </asp:UpdatePanel>

        </div>

        <asp:UpdateProgress ID="UpdateProgress1" runat="server">

            <ProgressTemplate>

             <img src="ajax-loader.gif" />

            </ProgressTemplate>

        </asp:UpdateProgress>

    </form>

C# KODU:

  protected void Button1_Click(object sender, EventArgs e)

    {

 

        //program da update progress üzerine şu adresten download edilen bir resim atılır:http://ajaxload.info/

        System.Threading.Thread.Sleep(3000);//3 saniye bekletmek için compiler ı

        Label1.Text = "MEHMET YARLUĞKAL";

    }

g-Validator Calloud Extender Kontrolü

HTML KODU:

<form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server" />

        <div>

            <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 16px; position: absolute;

                top: 55px"></asp:TextBox>

            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"

                ErrorMessage="lütfen bu kısmı boş geçmeyin" Style="z-index: 101; left: 179px;

                position: absolute; top: 56px" Display="None"></asp:RequiredFieldValidator>

            &nbsp;<br />

          <br />

           <asp:Button ID="Button1" runat="server" Height="28px" Style="z-index: 103; left: 256px;

            position: absolute; top: 132px" Text="tıkla" Width="45px" />

           

              <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="RequiredFieldValidator1">

        </cc1:ValidatorCalloutExtender>

        </div>

               

              

      

      

    </form>

h-Web Service'i kullanarak Autocomplete Extender Kontrolünü kullanma:

HTML KODU:

<form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server" />

        <asp:TextBox ID="TextBox1" runat="server" Width="224px"></asp:TextBox><div>

            <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="3" ServiceMethod="GetProducts" ServicePath="WebService.asmx" TargetControlID="TextBox1">

            </cc1:AutoCompleteExtender>

            &nbsp;</div>

        &nbsp; &nbsp;

    </form>

APP_CODE  Klasörü içinde bulunan webservice in cs uzantılı böülümünün kodu:

using System;

using System.Configuration;

using System.Data;

using System.Data.SqlClient;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Web.Script.Services;

 

/// <summary>

/// Summary description for WebService

/// </summary>

[ScriptService]

[WebService(Namespace = "http://tempuri.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class WebService : System.Web.Services.WebService

{

 

    string query;

    string kaynak = @"Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Documents and Settings\YARLUĞKAL\Desktop\AJAXEnabledWebSite1\App_Data\Databas.mdf';Integrated Security=True;Connect Timeout=30;User Instance=True";

    SqlDataReader dr;

    SqlCommand cmd;

    SqlConnection scon;

  

 

    private void openconn()

    {

        scon = new SqlConnection(kaynak);

        scon.Open();

 

    }

    public WebService()

    {

        //Uncomment the following line if using designed components

        //InitializeComponent();

    }

    [WebMethod]

    public string[] GetProducts(string prefixText)

    {

        openconn();

 

        string sql = "Select * from product Where name like @prefixText";

        SqlDataAdapter da = new SqlDataAdapter(sql, "Data Source=.\\SQLEXPRESS;AttachDbFilename='C:\\Documents and Settings\\YARLUĞKAL\\Desktop\\AJAXEnabledWebSite1\\App_Data\\Databas.mdf';Integrated Security=True;Connect Timeout=30;User Instance=True");

       

        da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText + "%";

        DataTable dt = new DataTable();

        da.Fill(dt);

        string[] items = new string[dt.Rows.Count];

        int i = 0;

        foreach (DataRow dr in dt.Rows)

        {

            items.SetValue(dr["name"].ToString(), i);

            i++;

        }

        return items;

        scon.Close();

    }

}

ÜCRETSİZ KPSS VİDEO DERSLER, TESTLER BURADA TIKLAYINIZ


BENZER KONULARI SİTE İÇİNDE ARAYIN










  • SİTE İÇİ ARAMA
  • Kariyerdersleri.com
  • KATEGORİLER
  • HAKKIMIZDA
Mutlu olmayı yarına bırakmak, karşıya geçmek için nehrin durmasını beklemeye benzer ve bilirsin, o nehir asla durmaz.
KPSS MATEMATİK KPSS GEOMETRİ KPSS VATANDAŞLIK KPSS TÜRKÇE KPSS TARİH KPSS COĞRAFYA
İNGİLİZCE ALMANCA İTALYANCA KARİYER OYUN BİLGİSAYAR YAZILIM BİLGİSAYAR NETWORK
BİLGİSAYAR DONANIM BİLİŞİM TERİMLERİ CİLT VE CİLT BAKIMI HASTALIKLARIMIZ İNSAN VÜCUDU NEDİR