Showing posts with label alli. Show all posts
Showing posts with label alli. Show all posts

Wednesday, March 28, 2012

Why My AutocompleteExtender doesnt work Im gone crazy!!

Hi All!!!

I'm looking for help. I read lot of post in this forum but my AutocompleteExtender still not work. Can somebody help please!

this is my code behind of my Webservice

1using System;2using System.Data.SqlClient;3using System.Web;4using System.Collections;5using System.Collections.Generic;6using System.Web.Services;7using System.Web.Services.Protocols;8910/// <summary>11///12/// </summary>13[System.Web.Script.Services.ScriptService]14[WebService(Namespace ="http://tempuri.org")]15[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1, EmitConformanceClaims = true)]16public class AutocompleteList : System.Web.Services.WebService {1718 public AutocompleteList () {1920//Uncomment the following line if using designed components21 //InitializeComponent();22 }2324 [WebMethod]25 [System.Web.Script.Services.ScriptMethod]26 public string[] GetList(string prefixe, int count)27 {28 List<string> art = new List<string>();29 string cnx = global::System.Configuration.ConfigurationManager.ConnectionStrings["artistesSQLServices"].ConnectionString;30 string select = "SELECT DISTINCT nom FROM [Table] WHERE nom LIKE @dotnet.itags.org.VALUE";31 SQLServer server = new SQLServer(cnx);32 if (server.Connect.State == System.Data.ConnectionState.Open)33 {34 SqlDataReader reader = null;35 SqlCommand cmd = new SqlCommand(select, server.Connect);36 cmd.Parameters.Add(new SqlParameter("@dotnet.itags.org.VALUE","%" + prefixe + "%"));37try38 {39 reader = cmd.ExecuteReader();40 cmd.Parameters.Clear();41 }42catch (Exception ex)43 {44string mess = ex.Message;45 }46finally47 {48if (reader.HasRows)49 {50while (reader.Read())51 {52 art.Add(reader.GetValue(0).ToString());53 }54 }55 reader.Close();56 reader.Dispose();57 cmd.Dispose();58 server.SQLDisconnect();59 }60 }61return art.ToArray();62 }63}

this is the code of my aspx page

<%

@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/users/Site.master"AutoEventWireup="true"

CodeFile

="Test.aspx.cs"Inherits="users_Test"Title="Untitled Page" %>

<%

@dotnet.itags.org.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TagPrefix="asp" %>

<%

@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:ScriptManagerID="ScriptManager1"runat="server"EnablePageMethods="true"EnablePartialRendering="true"></asp:ScriptManager><ajaxToolkit:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"TargetControlID="TextBox2"ServiceMethod="GetList"ServicePath="../AutocompleteList"CompletionInterval="10"CompletionSetCount="10"MinimumPrefixLength="3"Enabled="true"EnableCaching="true"></ajaxToolkit:AutoCompleteExtender> <asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>

</

asp:Content>

Hi,

Change your First Parameter "string prefixe" to be "string prefixText" . The Parameters are hard-coded in the WebService Invocation.

Check this Thread ..http://forums.asp.net/1598039/ShowThread.aspx#1598039


thanks for your help phanatic it works very well ............ BUT in debug mode only

when i call my page by this url :http://mymachine/mypage.aspx the autocompletion doesn't work. Do you know why?


ok,

we are making progressSmile

I see that you are calling an ASPX Page , are you trying to use the PageMethods ?

If you are , Please checkhttp://forums.asp.net/thread/1205564.aspx

If it resolves your issue , please mark my reply as the answer


still doesn't work!

I have "myage.aspx" which contains the autocompleteextender, and 2 others files (Autocomplete.asmx and Autocomplet.cs) which contains the code of my webservice


still doesn't work!

I have "myage.aspx" which contains the autocompleteextender and the two files of my webservice the "Autocomplet.asmx" and the code-behind "Autocomplete.cs"


hi,

Please drop me a sample at Phani_Rajyn@.yahoo.co.in


i've just sent you a sample

Hi ,

The sample contains SQLDataSource Connections and a lot of dependencies .

I cannot run this on my machine

can you please send me a self-contained sample that can run anywhere ?


hi phana

i've done some test with an other code in my webservice like this

1[WebMethod]2 [System.Web.Script.Services.ScriptMethod]3public string[] GetCompletionList(string prefixText,int count)4 {5int i = 0;6int iLength = 10;7 List Values =new List<string>();8for (i = 0; (i < iLength); i++)9 {10 Values.Add(Convert.ToString(prefixText + i.ToString()));11 }12 String[] strReturn =new String[Values.Count];13 strReturn = Values.ToArray();14return (strReturn);15 }

this code work very fine in debug mode and in normal mode. In my code i'm connecting to a SQLSERVER 2005 in an other machine.


I've done a test

I code a new page aspx just with the textbox an the autocompleteextender

i try my webservice it works fine. but when i add my website in IIS the autocompletextender doesn't work. it seems to be an issue in my IIS settings con you tell me what are the settings for IIS please


Hi,

"this code work very fine in debug mode and in normal "

If the code above works , then there are no issues with the AutoCompleteExtender , you should investigate the calls to the SQL Server you are making to understand what the issue is .

As far as IIS is concerned, are you gettting any errors related to IIS configuration ?


i find the issue it seems that IIS don't use my authentification to connect to the sqlserver

i've change my connection string and use the "sa" id user and password to connect

thx a lot for your help phana


just an other question can tell me how can i do a drag n drop from a textbox to an other textbox?

Hi,

great to know that we resolved the issue.

Can you please mark my reply as the answer ?

Monday, March 26, 2012

Wish: ClientSide EventHandling By Reference

Hello to all!

I have discovered that event handling in the client side is done by copying the function into the event handler list array and not by referencing it. That is very bad I think. I wish for the next release of the MS Ajax Library an event handling by reference. Below is some code to make clear, what I am meaning.

1 Type.registerNamespace('Demo');23 Demo.Class1 = function () {4this.className ='this is class one';5 _evtHandler =new Sys.EventHandlerList();6 }7 Demo.Class1.prototype = {8 addDoSomethingEventHandler: function (handler) {9 _evtHandler.addHandler('onDoSomething', handler);10 },11 removeDoSomethingEventHandler: function (handler) {12 _evtHandler.removeHandler('onDoSomething', handler);13 },14 doSomething: function () {15 alert('I am doing something.');16 var f = _evtHandler.getHandler('onDoSomething');17if(f) {18 f();19 }20 },21 dispose: function() {22 alert('I am disposing now (' +this.className +')');23 }24 }25 Demo.Class1.registerClass('Demo.Class1',null, Sys.IDisposable);2627 Demo.Class2 = function (id) {28this.className ='this is class two.';29this._id = id30 }31 Demo.Class2.prototype = {32 methodOne: function () {33 alert('ID: ' +this._id +'\nMethod One knows that something is done.');34 },35 methodTwo: function () {36 alert('ID: ' +this._id +'\nMethod Two knows that something is done.');37 },38 methodThree: function () {39 alert('ID: ' +this._id +'\nMethod Three knows that something is done.');40 },41 dispose: function () {42 alert('I am disposing now (' +this.className +')');43 }44 }45 Demo.Class2.registerClass('Demo.Class2',null, Sys.IDisposable);4647 var obj1 =new Demo.Class1();48 var obj2 =new Demo.Class2('obj2');49 var obj3 =new Demo.Class2('obj3');5051 obj1.addDoSomethingEventHandler(obj2.methodOne);52 obj1.addDoSomethingEventHandler(obj2.methodTwo);53 obj1.addDoSomethingEventHandler(obj3.methodOne);54 obj1.doSomething();55 obj2.methodOne = function () {56 alert('Someone has overwritten me.');57 };58 obj1.removeDoSomethingEventHandler(obj2.methodOne);59 obj1.doSomething();60 obj2.methodOne();61 obj3.methodThree();

First observaion is that becauseobj2.methodOne() has been over written id couldn't removed from the event handler list. The second one is that the variablesthis._id are undefined when calling the functions by raising the event. Calling the methods directly from an instance does work, see line 61.

I need some workaround to save an instance, too, not only a copy of its methods in order their instance variables are not undefined. Any Ideas are welcome.

Yavuz

First of all your code seems to be buggy.

obj1.addDoSomethingEventHandler(obj2.methodOne);

When the methodOne is invoked the this pointer will not be obj2.

Here is the fix.

var fn = Function.createDelegate(obj2, obj2.methodOne);

obj1.addDoSomethingEventHandler(fn);

Now you can remove the handler using

obj1.removeDoSomethingEventHandler(fn);

This is unaffected whether or not you set obj2.methodOne to something else.


Hello Rama!

That was not a bug. It was a question how to solve this problemSmile Thank you for your answer.

Now the function is copied into the delegate. Ifobj2.methodOne() is changed, the changed method isn't invoked. But thats another story I think. It's a situation which occurs rarely i think where you have to change a method at run-time.

I could not find a documentation about theFunction.createDelegate() method. Have I to go through the debug.js-files?

Yavuz


Looks like it has been not documented yet. The doc writers missed it. There are two function Function.createCallback and Function.createDelegate, they are widely used in ASP.NET AJAX. You can look at the source as it is easy to understand utility.

I will do it. Thank you.

Saturday, March 24, 2012

Works in IE but not in Firefox ...

Hi all

I have a simple script for those of you who are not scared of a bit of Javascript, which works perfectly in IE, but fails in Firefox with the following error

Error: uncaught exception: [Exception... "Not enough arguments [nsIDOM3Node.getUserData]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame ::http://localhost:2690/AtlasAprilCTPTests/Default.aspx :: onclick :: line 1" data: no]

Here is the code, pretty simple stuff. Any ideas anyone?

<%@dotnet.itags.org.PageLanguage="C#"%>
<%@dotnet.itags.org.ImportNamespace="System.Web.Services" %>
<%@dotnet.itags.org.ImportNamespace="System.Data" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"EnableScriptComponents="true"runat="server"/>
<scripttype="text/C#"runat="server">
[WebMethod]
publicDataTable getUsers()
{
DataSet1TableAdapters.tblUsersTableAdapter da =new DataSet1TableAdapters.tblUsersTableAdapter();
return da.GetData();
}
</script>
<scripttype="text/javascript">
function getUserData()
{
PageMethods.getUsers(reportData, reportTimeOut, reportError);
}
function reportData(result)
{
if(result)
{
var sb =new Array();
sb.push("<table border=1 style=\"border-collapse:collapse;\"><tr><td>UserID</td><td>Firstname</td><td>Surname</td><td>DOB</td><td>isSubscribed</td></tr>");
for(var i=0; i<result.get_length();i++)
{
sb.push("<tr><td>" + result.getItem(i).get_rowObject().UserID +"</td><td>" + result.getItem(i).get_rowObject().FirstName +"</td><td>" + result.getItem(i).get_rowObject().Surname +"</td><td>" + result.getItem(i).get_rowObject().DOB +"</td><td>" + result.getItem(i).get_rowObject().isSubscribed +"</td></tr>");
}
sb.push("</table>");
$("result").innerHTML = sb.join("");
}
}
function reportError(result)
{
alert(result);
}
function reportTimeOut(result)
{
alert(result);
}
</script>
</head>
<body>
<formid="form1"runat="server">
<div>
<inputtype="button"value="Get Table From DB"onclick="getUserData();"/>
</div>
<divid="result"></div>
</form>
</body>
</html>

Cheers

Martin

Hi Martin,

For some reason, it appears that Firefox doesn't like the name 'getUserData'. Rename it and it should all work. Maybe the name conflicts with a built-in Firefox function or something like that.

Maybe someone else can provide an explanation?

thanks,
David


Yes David is correct. Th problem is with getUserData which is a function defined in the DOM level 3 specification.

http://www.w3.org/TR/DOM-Level-3-Core/idl-definitions.html

The DOM function needs a parameter of type string. So if you rename the function it will work out.