Showing posts with label autocomplete. Show all posts
Showing posts with label autocomplete. Show all posts

Saturday, March 24, 2012

Pure Ajax alternative for this atlas code

I want's to find out what will be the pure ajax that is client side script to get autocomplete functionality

that is for this atlas code
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" />
<div>
Enter a Name:
<asp:TextBox ID="txtName" runat="server" />
<atlas:AutoCompleteExtender ID="au" runat="server">
<atlas:AutoCompleteProperties Enabled="true" MinimumPrefixLength="1"
ServiceMethod="GetNames" ServicePath="MyNameService.asmx" TargetControlID="txtName" />
</atlas:AutoCompleteExtender>
</div>
</form>
where web service is

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MyNameService : System.Web.Services.WebService {

public MyNameService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string[] GetNames(string prefixText, int count)
{
ArrayList filterList = new ArrayList();
string[] names = { "AzamSharp", "Scott", "Simon", "Alan", "Michael", "Jane", "Janice" };

foreach (string str in names)
{
if (str.ToLower().StartsWith(prefixText.ToLower()))
{
filterList.Add(str);
}
}

return (string[]) filterList.ToArray(typeof(string));

}

[WebMethod]
public string HelloWorld() {
return "Hello World";
}

}

Hi,

can you tell us why you don't want to use Atlas? Is it because you're developing with ASP.NET 1.x? If so you can take a look at Ajax.NET.

Grz, Kris.


the example here does something along along the lines of what your looking for

http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=12


Mr X!!!
My Only Problem is lack of browsers support by atlas Like opera other it is the best and easiest of all ajax based technologies.
Mr X!!!
My Only Problem is lack of browsers support by atlas Like operaotherwise it is the best and easiest of all ajax based technologies.

hello.

though i haven't done it, i beleiver that you can try to adapt atlas to opera by writting a compat layer for it...i also don't know if one is needed...


Opera support is possible but it is currently a problem because of browser detection. A big issue is the lack of defineGetter and defineSetter mechanism. There would simply be no way to define custom DOM properties, in other words Atlas cannot have a compatability layer based on IE but would have to have use W3C DOM and create a compatability layer for IE.

There is really a lot of merit to this. Has the team considered this at all? I realize the IE dom was chosen as the base for reason of convenience (and I have read why) but there seems to be a few very good reasons to base it on W3C.

Not only would a W3C based Atlas that provides compatability layers for all browsers be The Right Thing but I think it can greatly help Atlas adoption throughout the whole web development community, not only the ASP/.NET/Windows/... community. I have already seen flame wars start because of this. There are tons more reasons I can think of why the W3C model for Atlas would be great.

The only reason I can think of for supporting the IE DOM model is to attract those more familiar with the model (ME!!!!).

Opera is an interesting browser with many oddities and a tiny market share (last I checked less than 2 percent) and I am sure before a full version of Atlas is released Atlas will support Opera. I personally do not worry about Opera too much, I am more interested in full Safari support.

REQEST: The Safari compatability layer can really use a unified solution for loading dynamic scripts. I currently have to use callbacks within the dynamically loaded script to know it is available... no onload or readystatechange... not cool. An iframe solution seems possible but I have not tried this yet. Another solution is to use a webrequest and eval but also have not tried this yet.


hum...man, i really love opera! btw, have you noticed that it has passed the acid test (version 9 beta)?

Luis - yeah I think Opera has the right idea make all their browsers (mobile, device and pc) run the same way. I've been playing with Opera 9 beta and its looking pretty good so far. I really think they need to rethink Opera and make it less complex for the novice users. I can see why a developer has an option to identify as Mozilla but a regular user? I personally wouldn't recommend Opera to my mom/dad...


hello again.

well, sorry, this is a biased opinion :) i recommend opera to everyone!

Purpose of "AllowPartialRendering=true"

WHen I used "Autocomplete" contorl of Atlas, I did not need the scriptmanager to have the above attribute to be set specificcally to true and everything worked great.

However, when I started using web parts where I had two calendars in two web part zones, as soon as I clicked on a date in one calendar, i could see the entire page refresh. When i set the above mentioned parameter to true, that thing went away.

So when to set this parameter to true or is it required always?

When you use the UpdatePanel control, setting the EnablePartialRendering property to True allows you to get a partial page rendering...
When you use the UpdatePanel control, setting the EnablePartialRendering property to True allows you to get a partial page rendering...

Question about AutoCompleteExtender and DelimiterCharacters

Hello, I'm developing and application that uses the autocompleteextender.

This autocomplete should work more or less as the "add adress" bar in an email program. You introduce text, the app suggests something, you choose any suggestion then write a ";" and start de process again until you got al your adresses neatly separated by ";" in a multiline textbox;

Via the DelimiterCharacters i'm getting this effect using ";" as the delimiter character. What I don′'t like is the way it renders after you have chosen one field:

Example

See what I mean? I don't want the "El inquilino comunista" in front of every suggestion, I've already choosen it. The more suggestions you choose the more confusing it becomes:

Example

I would like the suggestions to be (after i've already chosen "El Inquilino Comunista" and "The White Stripes")

Alan Sparhawk
Alanis Morisette
Alasdair Roberts ...

Any ideas how to acomplish it?

Thank you.

Hi,

I think you may accomplish this in the server side method that fills the DropDownlist.

1. Get the last word separated by the delimiter

2. Fill results according to the word.

For instance:

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string[] GetCompletionList(string prefixText, int count)
{
string[] result = new string[16];
int index = prefixText.LastIndexOf(";");
if(index >= 0)
prefixText = prefixText.Substring(index);

for (int i = 0; i < 16; i++)
{
result[i] = prefixText + i.ToString();
}
return result;
}

Hope this helps.

Question about AutoComplete textbox

The ASP.NET AJAX Control Toolkit AutoComplete textbox uses a webservice to retrieve a list of suggestions "based on what the user has typed in". I want to create a list of suggestions based on "what the user has typed in" PLUS "the values of some other fields on the form". How can this be done? I don't see a way to access the other field values within the webservice that the AutoComplete textbox uses.

Seems like a reasonable feature request. I have opened work itemhttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=8414 to track this.

Thanks,

Kirti


Thanks Kirti, that would be great! Is there a temporary workaround I can use? I need to auto complete a textbox for zip codes. The zipcodelist is limited to the country the user selects in a dropdownlist. The the autocomplete webservice should take country as additional parameter.

Question About AutoComplete

Hello,

I have setup a page containing two text box which utilize the AutoComplete Extension and work perfectly (thanks to the video helps), but I would like to extend this a bit. I would like to use the variable that had been put into the first text box, to restrict what is displayed in the second auto complete. Basically, once I am within my autocomplete.asmx file, how to I get the variable of what was in the first text box to pass into my stored procedure?

Thanks,

Chris

What you want to do is use the contextKey parameter. It's described in thedocumentation for the extender.


Hrm, this is very close, but I still do not see how to assign the text, or a variable, to the ContextKey? I can see how to pass a static piece of text in, which I have had success with, but have not had to much luck with the variable.

Thanks,

Chris


You can use $find('AutocompleteExtenderClientID').set_contextKey() to set that on the client side. So, you'd want to use $addHandler to handle the context textbox's onchange event and update the autocomplete extender's contextKey with the textbox's new value.

Is this what you were talking about? I get some errors when I try to compile it. Also, is there a way to Prepend the text it is going to set?

Thanks so much,

Chris

1<asp:TextBox ID="PortName" runat="server" OnTextChanged=$find('AutoCompletePortName').set_contextKey()></asp:TextBox>23<cc1:AutoCompleteExtender ID="AutoCompletePortName" runat="server" TargetControlID="PortName" ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="3" CompletionSetCount="5" ContextKey=$addHandler UseContextKey=True>4 </cc1:AutoCompleteExtender>5


You might be able to do this, but I haven't tested it:

<cc1:AutoCompleteExtender ID="AutoCompletePortName" runat="server" TargetControlID="PortName" ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="3" CompletionSetCount="5" ContextKey="$get('<%= PortName.ClientID%>').value" />

If it works, that's going to be the easiest way to do it. Also, you don't have to explicitly set UseContextKey. If a ContextKey is specified, it will automatically use it.

$addHandler is a little bit more complicated than that. You can see a few examples of using it here:http://encosia.com/2007/11/15/exploring-one-of-ms-ajaxs-often-overlooked-features/