Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to set JIT type? Pin
Dragonfly_Lee1-Feb-09 0:54
Dragonfly_Lee1-Feb-09 0:54 
GeneralRe: How to set JIT type? Pin
Eddy Vluggen1-Feb-09 7:36
professionalEddy Vluggen1-Feb-09 7:36 
GeneralRe: How to set JIT type? Pin
Dragonfly_Lee1-Feb-09 18:19
Dragonfly_Lee1-Feb-09 18:19 
QuestionProblem of Fonts When Export Crystal Report in PDF PinPopular
Wlink31-Jan-09 17:59
Wlink31-Jan-09 17:59 
QuestionPythagorean triplet Pin
Matthew Hazlett31-Jan-09 17:48
Matthew Hazlett31-Jan-09 17:48 
AnswerRe: Pythagorean triplet Pin
Matthew Hazlett31-Jan-09 17:58
Matthew Hazlett31-Jan-09 17:58 
AnswerRe: Pythagorean triplet Pin
Matthew Hazlett31-Jan-09 21:14
Matthew Hazlett31-Jan-09 21:14 
QuestionAutocomplete AJAX Pin
CrimeanTurtle200831-Jan-09 17:05
CrimeanTurtle200831-Jan-09 17:05 
Hi All,

I am currently working on using the ajax autocomplete application that queries from the database for the input entered into the textbox. However nothing shows when i load it up and i am unsure as to whether it is to do with the way i have created the web method or maybe to to do with the static method. Nonetheless it does not work.
Would anyone be able to provide assistance for this? Many Thanks + Kind Regards.

<br />
-Class<br />
<br />
using System;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Linq;<br />
using System.Web;<br />
using System.Web.Security;<br />
using System.Web.UI;<br />
using System.Web.UI.HtmlControls;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
using System.Xml.Linq;<br />
using System.Web.Services;<br />
using System.Data.SqlClient;<br />
<br />
/// <summary><br />
/// Summary description for MyClass<br />
/// </summary><br />
public class MyClass<br />
{<br />
	public MyClass()<br />
	{<br />
		//<br />
		// TODO: Add constructor logic here<br />
		//<br />
	}<br />
<br />
<br />
<br />
   <br />
    public static string [] GetCountry(string country)<br />
    {<br />
<br />
        string query = "SELECT DISTINCT COUNTRY FROM CUSTOMERS WHERE COUNTRY LIKE @Country";<br />
        using (SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\NORTHWIND.MDF;Integrated Security=True;User Instance=True"))<br />
        {<br />
           <br />
            SqlDataAdapter adapter = new SqlDataAdapter(query, conn);<br />
            adapter.SelectCommand.Parameters.Add("@Country", SqlDbType.VarChar, 15).Value = country + "%";<br />
            DataTable dt = new DataTable();<br />
            adapter.Fill(dt);<br />
            string[] items = new string[dt.Rows.Count];<br />
            int i = 0;<br />
             foreach (DataRow dr in dt.Rows)<br />
            {<br />
                items.SetValue(dr["Country"].ToString(), i);<br />
               <br />
                i++;<br />
            }<br />
            return items;<br />
           <br />
<br />
            <br />
<br />
        }<br />
    }<br />
}<br />
<br />
<br />
-Web Method<br />
<br />
using System;<br />
using System.Collections;<br />
using System.Linq;<br />
using System.Web;<br />
using System.Web.Services;<br />
using System.Web.Services.Protocols;<br />
using System.Xml.Linq;<br />
<br />
/// <summary><br />
/// Summary description for WebService<br />
/// </summary><br />
[WebService(Namespace = "http://tempuri.org/")]<br />
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<br />
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. <br />
[System.Web.Script.Services.ScriptService]<br />
public class WebService : System.Web.Services.WebService {<br />
<br />
    public WebService () {<br />
<br />
        //Uncomment the following line if using designed components <br />
        //InitializeComponent(); <br />
    }<br />
<br />
    [System.Web.Services.WebMethod]<br />
    [System.Web.Script.Services.ScriptMethod]<br />
<br />
    public string [] GetMyCountry(string country)<br />
    {<br />
<br />
        return MyClass.GetCountry(country).ToArray();<br />
        <br />
<br />
    }<br />
    <br />
}<br />
<br />
- Source Code<br />
<br />
<![CDATA[<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>]]><br />
<br />
<![CDATA[<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>]]><br />
<br />
<br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server"><br />
    <title>Untitled Page</title><br />
    <style type="text/css"><br />
        .style1<br />
        {<br />
            width: 170px;<br />
        }<br />
    </style><br />
</head><br />
<body><br />
    <form id="form1" runat="server"><br />
    <div><br />
    <br />
        <table style="width: 100%; height: 161px;"><br />
            <tr><br />
                <td class="style1"><br />
                     </td><br />
                <td><br />
                     </td><br />
                <td><br />
                     </td><br />
            </tr><br />
            <tr><br />
                <td class="style1"><br />
                    Choose a Country</td><br />
                <td><br />
                    <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox><br />
                </td><br />
                <td><br />
                     </td><br />
            </tr><br />
            <tr><br />
                <td class="style1"><br />
<cc1:autocompleteextender id="AutoCompleteExtender1" runat="server" targetcontrolid="Textbox1" servicepath="WebService.asmx" servicemethod="GetMyCountry" minimumprefixlength="1" completionsetcount="12" enablecaching="true" xmlns:cc1="#unknown"></cc1:autocompleteextender></td><br />
                <td><br />
                    <asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown"><br />
                    <services><br />
                    <asp:servicereference path="WebService.asmx" /><br />
                    </services><br />
                    </asp:scriptmanager><br />
                </td><br />
                <td><br />
                     </td><br />
            </tr><br />
        </table><br />
    <br />
    </div><br />
    </form><br />
</body><br />
</html><br />
<br />
<br />

AnswerRe: Autocomplete AJAX Pin
Christian Graus31-Jan-09 22:17
protectorChristian Graus31-Jan-09 22:17 
Questionproblem with list&lt;&gt; Pin
raihansazal31-Jan-09 16:48
raihansazal31-Jan-09 16:48 
AnswerRe: problem with list&lt;&gt; Pin
Dragonfly_Lee31-Jan-09 21:06
Dragonfly_Lee31-Jan-09 21:06 
NewsRe: problem with list&lt;&gt; Pin
raihansazal18-Feb-09 22:10
raihansazal18-Feb-09 22:10 
Questionprintout contents from listview and from textboxes Pin
Najmal31-Jan-09 13:38
Najmal31-Jan-09 13:38 
AnswerRe: printout contents from listview and from textboxes Pin
Christian Graus31-Jan-09 14:06
protectorChristian Graus31-Jan-09 14:06 
GeneralRe: printout contents from listview and from textboxes Pin
Najmal31-Jan-09 14:33
Najmal31-Jan-09 14:33 
Question[Solved]Show two decimal places in DataGridViewTextBoxCell [modified] Pin
Jordanwb31-Jan-09 12:28
Jordanwb31-Jan-09 12:28 
AnswerRe: Show two decimal places in DataGridViewTextBoxCell Pin
Christian Graus31-Jan-09 12:45
protectorChristian Graus31-Jan-09 12:45 
GeneralRe: Show two decimal places in DataGridViewTextBoxCell [modified] Pin
Jordanwb31-Jan-09 12:52
Jordanwb31-Jan-09 12:52 
GeneralRe: Show two decimal places in DataGridViewTextBoxCell Pin
Christian Graus31-Jan-09 13:04
protectorChristian Graus31-Jan-09 13:04 
AnswerRe: Show two decimal places in DataGridViewTextBoxCell Pin
Najmal31-Jan-09 13:27
Najmal31-Jan-09 13:27 
GeneralRe: Show two decimal places in DataGridViewTextBoxCell Pin
Jordanwb31-Jan-09 14:12
Jordanwb31-Jan-09 14:12 
GeneralRe: Show two decimal places in DataGridViewTextBoxCell Pin
Najmal31-Jan-09 14:42
Najmal31-Jan-09 14:42 
GeneralRe: Show two decimal places in DataGridViewTextBoxCell Pin
Jordanwb31-Jan-09 15:43
Jordanwb31-Jan-09 15:43 
Question[Message Deleted] Pin
hkjghkj131-Jan-09 6:40
hkjghkj131-Jan-09 6:40 
AnswerRe: Problem with image and PictureBox Pin
Najmal31-Jan-09 7:43
Najmal31-Jan-09 7:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.