Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Wednesday, March 28, 2012

ASP.NET AJAX Javascript Localization using Database

Hi,

I've been looking at ASP.NET AJAX Javascript localization example by using embedded resource file in assembly and

setting the EnableScriptLocalization property in ScriptManager. It worked nicely, however, I would like to store the resources

in the database. ASP.NET 2.0 allows you to write your own Resource provider. See this articlehttp://msdn2.microsoft.com/en-us/library/aa905797.aspx

However, I haven't found any similar information on how to do that in ASP.NET AJAX.

Does anyone aware about this functionality in ASP.NET AJAX?

Hi,

The RecourceHandler in the ScriptManager is a static member of fixed type, you can't replace it with your own one.

So, there is no such elegant way to achieve it like the one in the article you mentioned.

ASP.NET AJAX Incomplete Documentation

While the docs are pretty nice, nicely formatted and have some decent examples, theyre very incomplete.

Just as an example; try to find Sys.Browser anywhere on the docs site. I sure cant.

When is the documentation going to be updated and complete?

That is screwing me as well. Instead of giving us the documentation your soon here microsoft annoucing another version of ajax! also un-documented.


Thank you for this feedback, and I am sorry Sys.Browser is missing from the documentation. I will find out when documentation for Sys.Browser will be published.


Thanks again for the feedback. This class will be documented and I'll post a link to this thread when it is ready.


Gosh, if documentation of a javascript function were 'screwing' me, I'd probably go do something crazy like, I don't know, open the ajax.debug.js file and look at the available methods and their signatures.

But that's just me.

Monday, March 26, 2012

ASP.NET AJAX Autocomplete with VB

Finally I got this to work with VB -

My first step was to get the example ajax application working: http://ajax.asp.net/default.aspx?tabid=47&subtabid=471

Of course there is no VB example - So I converted the C example to VB - which was pretty easy since I only needed the autocomplete and none of the other examples.

The only way I could get the autocomplete to work was to have the webservice written in C instead of VB. Everything I checked shows the VB and C# web services as identical.

So... does autocomplete not work with VB webservices?

This works for me

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Autocomplete
Inherits System.Web.Services.WebService
Private Shared autoCompleteWordList As String()

<WebMethod()> _
Public Function GetWordList(ByVal prefixText As String, ByVal count As Integer) As String()

If (autoCompleteWordList Is Nothing) Then
Dim temp() As String = IO.File.ReadAllLines(Server.MapPath("~/App_Data/words.txt"))
Array.Sort(temp, New CaseInsensitiveComparer)
autoCompleteWordList = temp
End If
Dim index As Integer = Array.BinarySearch(autoCompleteWordList, prefixText, New CaseInsensitiveComparer)
If (index < 0) Then
index = Not index
End If
Dim matchingCount As Integer
matchingCount = 0
Do While ((matchingCount < count) _
AndAlso (index _
+ (matchingCount < autoCompleteWordList.Length)))
If Not autoCompleteWordList((index + matchingCount)).StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase) Then
'TODO: Warning!!! break;If
End If
matchingCount = (matchingCount + 1)
Loop
Dim returnValue() As String = New String((matchingCount) - 1) {}
If (matchingCount > 0) Then
Array.Copy(autoCompleteWordList, index, returnValue, 0, matchingCount)
End If
Return returnValue
End Function
End Class

<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server">
</atlas:ScriptManager>
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:TextBox ID="TextBox1" runat="server" Width="1010px"></asp:TextBox>
<atlas:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server">
<atlas:AutoCompleteProperties TargetControlID="TextBox1" Enabled="True" ServicePath="AutoComplete.asmx"
ServiceMethod="GetWordList" MinimumPrefixLength="1" />
</atlas:AutoCompleteExtender>
</div>
</form>


I am using your code to solve a problem that I am having.

I need modify it a bit to work with a database.

Can you help me out with this?

Thanks


Im trying this method the vb is good. i downloada words.txt that help.

but i try to run it on my website and is not working other ajax enable work like the passwordstrengt.


I presume you can do the lookup straight from SQL server rather than use a web service?

Did you get any replies as this is exactly what I would like to do.

cheers

Mike


Hi,

i install the AjaxControlToolkit, but AutoComplete doesn't want to work.

I search the web and find samples with the microsoft atlas dll.

I managed to use this dll and AutoComplete works fine.

Microsoft.web.atlas.dll and AjaxControlToolkit.dll seem not to work on the same page.

How can I solve my problem (make work AutoComplete Control) only using AjaxControlToolkit.dll.

Here, you can download my simple code to test: http://promesses.planet-work.com/fic/ajax.zip

Thank for your help


Here is some code that I wrote up to work with a database. It's in VB.NET for all those VB heads out there. Hopefully this will help all of you.

<%@.WebServiceLanguage="VB"Class="PartnerList" %>

Imports

System.Web

Imports

System.Web.Services

Imports

System.Web.Services.Protocols

Imports

System.Collections.Generic

Imports

System.Data

Imports

System.Data.SqlClient

Imports

System.Configuration

<System.Web.Script.Services.ScriptService()> _

<WebService(Namespace:=

"http://www.commpartners.us/webservices", Description:="Webservice to allow a autocompleter service lookup")> _

<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

Public

Class PartnerListInherits System.Web.Services.WebService

<WebMethod(Description:=

"Method to retrieve Partner List")> _PublicFunction GetPartnerList(ByVal prefixTextAsString,ByVal countAsInteger)As ArrayDim SqlConnection1AsNew SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))Dim SqlCommand1AsNew SqlCommand("SELECT DISTINCT TOP(@.nrows) (COMP + ':' + NAME) As PartnerName From dbo.WhiteList WHERE Name Like @.term", SqlConnection1)

SqlCommand1.Parameters.AddWithValue(

"nrows", count)

SqlCommand1.Parameters.AddWithValue(

"term", prefixText &"%")Dim suggestionsAsNew List(OfString)

SqlConnection1.Open()

Dim drAs SqlDataReader = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection)

While dr.Read

suggestions.Add(dr(0).ToString)

EndWhile

Return suggestions.ToArray

EndFunction

End

Class

And for the front facing code:<asp:TextBoxID="SearchPartner"runat="server"Width="216px"></asp:TextBox>
<asp:ButtonID="FindBtn"runat="server"OnClick="FindPartner"Text="Find"/>
<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteSearch"MinimumPrefixLength="1"CompletionInterval="300"CompletionSetCount="10"runat="server"TargetControlID="SearchPartner" ServicePath="PartnerList.asmx"ServiceMethod="GetPartnerList"/
Also if you are wondering why my SQL query has (COMP + ':' + NAME) it's so I can show both an ID and concat it with the Company Name.

Have fun with the code and let me know if you have any problems.

JoeWeb


Nobody can help me ?

HI,

Sorry for my loging to our discussion , but i face the same problem with the autocompleteExtender that does not work with my VB.net project where the all other Controltookit work fine,..

i do the same steps which u wrote here but until know nothing happend and none of my code execute ,..........


JoeWeb:

Here is some code that I wrote up to work with a database. It's in VB.NET for all those VB heads out there. Hopefully this will help all of you.

<%@.WebServiceLanguage="VB"Class="PartnerList" %>

Imports

System.Web

Imports

System.Web.Services

Imports

System.Web.Services.Protocols

Imports

System.Collections.Generic

Imports

System.Data

Imports

System.Data.SqlClient

Imports

System.Configuration

<System.Web.Script.Services.ScriptService()> _

<WebService(Namespace:=

"http://www.commpartners.us/webservices", Description:="Webservice to allow a autocompleter service lookup")> _

<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

Public

Class PartnerListInherits System.Web.Services.WebService

<WebMethod(Description:=

"Method to retrieve Partner List")> _PublicFunction GetPartnerList(ByVal prefixTextAsString,ByVal countAsInteger)As ArrayDim SqlConnection1AsNew SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))Dim SqlCommand1AsNew SqlCommand("SELECT DISTINCT TOP(@.nrows) (COMP + ':' + NAME) As PartnerName From dbo.WhiteList WHERE Name Like @.term", SqlConnection1)

SqlCommand1.Parameters.AddWithValue(

"nrows", count)

SqlCommand1.Parameters.AddWithValue(

"term", prefixText &"%")Dim suggestionsAsNew List(OfString)

SqlConnection1.Open()

Dim drAs SqlDataReader = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection)

While dr.Read

suggestions.Add(dr(0).ToString)

EndWhile

Return suggestions.ToArray

EndFunction

End

Class

And for the front facing code:<asp:TextBoxID="SearchPartner"runat="server"Width="216px"></asp:TextBox>
<asp:ButtonID="FindBtn"runat="server"OnClick="FindPartner"Text="Find"/>
<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteSearch"MinimumPrefixLength="1"CompletionInterval="300"CompletionSetCount="10"runat="server"TargetControlID="SearchPartner" ServicePath="PartnerList.asmx"ServiceMethod="GetPartnerList"/
Also if you are wondering why my SQL query has (COMP + ':' + NAME) it's so I can show both an ID and concat it with the Company Name.

Have fun with the code and let me know if you have any problems.

JoeWeb

Did any of you read my post? This code works and I have tested it... COPY and Paste it and let me know how that works!

JoeWeb


DearJoeWeb

we do what exactly u do in the examle above , but nothing happened,..... so what is your suggession


DearJoeWeb

we do what exactly u do in the examle above , but nothing happened,..... so what is your suggession


I ame having the same problem where the autocomplete is not working.

When I try and run the code locally, which is running IE 6, I get a javascript error 'Sys.Debug is null or not an object', but I do not get a notification when running the page remotly on IE7.

The webservice is working when I go to the .asmx page locally.

Am I missing something? Do I need to register the web service somewhere?Help!!!


hi all

I had the same problem with the posted code how ever have solved it. You basically need to add the following to the page:

<asp:ScriptManager ID="ScriptManager1" runat="server" > <Services> <asp:ServiceReference Path="AutoComplete.asmx" /> </Services> </asp:ScriptManager>

I also changed the SqlConnection slightly as the method in the code above did not work:

Dim SqlConnection1As SqlConnection =New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("BVDB").ConnectionString)

hope this helps...

For me it works fine with MSSQL for tags. So I work with splitting Text by the last comma, if you do not need this, simply amend the code.

on aspx I have Script manager and

asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<

asp:TextBoxID="test1"runat="server"></asp:TextBox>

<

cc1:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"TargetControlID="test1"ServiceMethod="GetTags"ServicePath="UsedTags.asmx"MinimumPrefixLength="2"CompletionInterval="1000"EnableCaching="true"CompletionSetCount="12">

then UsedTags.asmx looks like

<%

@.WebServiceLanguage="VB"CodeBehind="~/App_Code/UsedTags.vb"Class="UsedTags" %>

then App_Code/UsedTags.vb looks like

Option Explicit On
Option Strict On
Option Compare Binary

Imports System.Data
Imports System.Data.SqlClient

Imports System.Collections.Generic

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class UsedTags
Inherits System.Web.Services.WebService

Private Shared autoCompleteWordList As String()

<WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Function GetTags(ByVal prefixText As String, ByVal count As Integer) As String()

Dim LastWord As String, _
ExpressionStart As String
If prefixText.Contains(",") AndAlso prefixText.LastIndexOf(",") < prefixText.Length Then
LastWord = prefixText.Substring(prefixText.LastIndexOf(",") + 1)
ExpressionStart = prefixText.Substring(0, prefixText.LastIndexOf(",") + 1)
Else
LastWord = prefixText
ExpressionStart = String.Empty
End If

Dim suggestions As New List(Of String)

If LastWord.Length > 0 Then
Dim connectionString As String
Using mySqlDbConnection As New SqlClient.SqlConnection()
connectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString

Dim mySqlDbCommand As New SqlClient.SqlCommand()
mySqlDbConnection.ConnectionString = connectionString
mySqlDbCommand.Connection = mySqlDbConnection
mySqlDbCommand.CommandType = CommandType.Text
mySqlDbCommand.CommandTimeout = 60
mySqlDbConnection.Open()

mySqlDbCommand.CommandText = "SELECT DISTINCT TOP(@.nrows) myTag FROM dbo.Tags WHERE myTag LIKE @.term ORDER BY myTag"
mySqlDbCommand.Parameters.AddWithValue("nrows", count)
mySqlDbCommand.Parameters.AddWithValue("term", LastWord & "%")

Dim ReaderData As SqlClient.SqlDataReader
ReaderData = mySqlDbCommand.ExecuteReader()

Do While ReaderData.Read
suggestions.Add(ExpressionStart & ReaderData(0).ToString)
Loop

ReaderData.Close()
mySqlDbConnection.Close()
End Using
End If

Return suggestions.ToArray
End Function
End Class

ASP.NET AJAX autocomplete with c#

Hey all,

I've been struggling with this AJAX autocomplete textbox in a c# app for the last day or so. I've found an example on these forums about getting the autocomplete control working in aVB app.

I have taken all of the VB suggestions and converted them all to c# but my textbox still doesn't call the web service. The textbox will just accept text and will never load the autocomplete options.

Here is what I have so far:

- AutoCompleteExtender defintion

<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"Enabled="true"EnableCaching="true"MinimumPrefixLength="1"TargetControlID="txtName"ServiceMethod="GetNames"ServicePath="~/WebServices/AutoComplete.asmx" />

- Web Service

using System;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Collections.Generic;

using System.Web.Script.Services;

[ScriptService()]

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

[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

publicclassAutoComplete : System.Web.Services.WebService

{

[WebMethod]

[ScriptMethod()]publicstring[] GetNames(string prefixText,int count){ ArrayList sampleList =newArrayList();
sampleList.Add("ABC");sampleList.Add("Hello");

sampleList.Add("Hi");

sampleList.Add("Hey");

ArrayList filteredList =newArrayList();

foreach (string sin sampleList)

{

if (s.ToLower().StartsWith(prefixText.ToLower()))

filteredList.Add(s);

}

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

}

}

- masterpage, ScriptManager definition

<asp:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"runat="server">

<Services>

<asp:ServiceReferencePath="~/WebServices/AutoComplete.asmx"/>

</Services>

</asp:ScriptManager>

Any help would be much appreciated.

TJ

Hi,

Generally, your code should be ok. Here is my sample that works fine, it's made according to your code.

MasterPage:

<%@. Master Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server"></asp:ScriptManager> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form></body></html>

Page:

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" Enabled="true" EnableCaching="true" MinimumPrefixLength="1" TargetControlID="txtName" ServiceMethod="GetNames" ServicePath="AutoComplete.asmx" /> </asp:Content>
Web Service:
 
<%@. WebService Language="C#" Class="AutoComplete" %>using System;using System.Web;using System.Collections;using System.Web.Services;using System.Web.Services.Protocols;using System.Collections.Generic;using System.Web.Script.Services;[ScriptService()][WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]public class AutoComplete : System.Web.Services.WebService{ [WebMethod] [ScriptMethod()] public string[] GetNames(string prefixText, int count) { ArrayList sampleList = new ArrayList(); sampleList.Add("ABC"); sampleList.Add("Hello"); sampleList.Add("Hi"); sampleList.Add("Hey"); ArrayList filteredList = new ArrayList(); foreach (string s in sampleList) { if (s.ToLower().StartsWith(prefixText.ToLower())) filteredList.Add(s); } return (string[])filteredList.ToArray(typeof(string)); }}
  
If it still doesn't work, please make sure there isn't any javascript error on your page. And use a traffic sniffer(e.g.: fiddler) to view the traffic to see if the server returns correct result.

Thanks for the response.

My only issue with the solution above is that it doesn't currently fit 100% in what my site is currently designed to produce. In your example you have the AutoCompleteExtender within an ASPX page that refers to the master page. Our site currently has the AutoCompleteExtender control defined in a nested user control structure AND the AutoCompleteExtender is wanted to be used inside a ModalPopupExtender. The first user control is referred to on a page that references the master page and falls within the asp:content tags that you also used.

PAGE (references User Control 1)

--> User Control 1 (content and refrerence to User Control 2)

--> User Control 2 (content and reference to ModalPopupExtender that includes AutoCompleteExtender)

The end result is:

- the Page contains a reference to User Control 1

- User Control 1 has a reference to User Control 2

- User Control 2 contains a couple of textboxes, and a ModalPopupExtender. There also is a panel defined on this control that will be the contents of the popup extender. Within this panel is were the AutoCompleteExtender is located.

Do you know if this is possible? I know this sounds confusing but if you would like some code examples of what I'm trying to accomplish, please let me know.

In the meantime I'm going to take your example and try to get it working using just the Page example. If I can get to that point I will start adding some user controls and popups into the mix to see if I can find out which piece is causing the issues.

Thanks again,
TJ


Yes, it definitely possible.

I think you've got a idea how to implement it, if it doesn't work, please follow my suggestion in previous post(Use fiddler).


Hey there,

You were right to try to suggest using Fiddler as a debugging tool because when running through the page using the AutoComplete textbox Fiddler returns an error. The error is:

System.InvalidOperationException: Request format is invalid: application/json; charset=utf-8.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

It is strange that even though the error is captured by Fiddler, the ASPX page shows no signs of errors.

The web service works as expected when going directly at the ASMX file and the Fiddler results are the following:

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<string>Hello</string>
<string>Hi</string>
<string>Hey</string>
</ArrayOfString>

I'm looking into the error that Fiddler is raising as we speak. If anyone has any information on the error that Fiddler is returning please let me know.

Thanks,

TJ


I've played with the "UseHttpGet=" and the "ResponseFormat=" settings on the ScriptMethod attribute with no luck. I also played with the ContentType of the Response object with no luck.

Anyone have any ideas on this error?

TIA,

TJ


It seems the problem is with the format of the request, you may peek into what's the value of it, still with Fiddler.


From Fiddler...

Request Raw View:

POST /Test.asmx/GetNames HTTP/1.1
Accept: */*
Accept-Language: en-us
Referer:http://localhost/Autocomplete/test.aspx
Content-Type: application/json; charset=utf-8
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)
Host: fin51311
Content-Length: 29
Proxy-Connection: Keep-Alive
Pragma: no-cache
Cookie: ASP.NET_SessionId=qeupjw45zwodqbvjmy4frf55

{"prefixText":"h","count":10}

Response Raw View:

HTTP/1.1 500 Internal Server Error
Server: Microsoft-IIS/5.1
Date: Thu, 16 Aug 2007 22:09:01 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 244

System.InvalidOperationException: Request format is invalid: application/json; charset=utf-8.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

Under the Caching tab of the Response Header section it reads:

HTTP/1.1 Cache-Control Header is present: private
private: This response MUST NOT be cached by a shared cache.

Is this something I should look at further?


Tiimmy,

I had the same and worked for a few hours looking at the problem you have. I found the solution to the problem.

I made a new AJAX enable site and copy the same sample sent to you before. It worked. They only thing that could be is that the handler section in the webconfig file is missing something. Make sure that it matches the section create by the project template.

I hope this helps.

Pablo.


Hey there,

Thanks for your reply. Taking your advice I created an AJAX-enabled web site and then tried to implement an AutoCompleteExtender. I am actually getting the same error as I was before. Nothing happens on the screen when you key in a character in the textbox.

After pressing a key (which should trigger a call to the web service) Fiddler logs a line in red, (error 500), that has private under the Caching column. In Fiddler, the Request Header section is displaying the Cache-Control as Pragma: no-cache, and the Response Headers section is displaying Cache-Control as private. Could this be an issue? Under the Caching tab of the Response header, the message reads:

Cache-Control Header is present: private
- private: This response MUST NOT be cached by a shared cache.

It may help if you can post examples of the files (web.config, *.asmx, *.aspx) that you are using to get it running?

Saturday, March 24, 2012

ASP.NET AJAX - Events calendar

I have been searching far and wide for an example showing how to update events on
an events calendar using ASP.Net AJAX.

The only examples I find are commercial modules or not ASP.Net AJAX.

If anyone has had more luck than I can you point me to the resource.

Thanks

Bump... Is anyone out there?

ASP.NET 2 - AJAX control toolkit autocomplete

hi

how can i do to have a session variable ( like for example session("name") ) to web site ( asp.net 2) in a class of control toolkit autocomplete.

with the use of this instructions in the class vb autocomplete :

Dim session As System.Web.SessionState.HttpSessionState

session = System.Web.HttpContext.Current.Session

the 'session' variable is nothing

thanks to attention

Hi Robby,

My understanding of your issue is that use session your WebService which is associated with a AutuCompleteExtender. If I have misunderstood, please feel free to let me know.

Based on this knowledge, here is a sample which is written by Jeffrey Zhao. I found it on MS WebCast. This sample is not use AutuCompleteExtender but they are similar. You can do some changes on your source code.

<%@. WebService Language="C#" Class="EnableSessionService" %>using System;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;using System.Web.Script.Services;using System.Web.SessionState;[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][ScriptService]public class EnableSessionService : System.Web.Services.WebService{ [WebMethod(true)] public int AddOne(){HttpSessionState session = HttpContext.Current.Session;object objValue = session["value"];int value = objValue == null ? 0 : (int)objValue;value++;session["value"] = value;return value; } }
Aspx page:
 
<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Enable Session</title></head><body> <form id="form1" runat="server"><asp:ScriptManager runat="server" ID="ScriptManager1" ScriptMode="Debug"><Services><asp:ServiceReference Path="Services/EnableSessionService.asmx" InlineScript="true" /></Services></asp:ScriptManager> <input type="button" value="Add One" onclick="addOne()" /><script language="javascript" type="text/javascript">function addOne(){EnableSessionService.AddOne(onSucceeded);}function onSucceeded(result){alert(result);}</script> </form></body></html>

Please pay attention to the "Bold" part. Hope this help.

Best regards,

Joanthan


Hi Joanthan

thanks to your advice, it's that i had necessity.

in my code i haven't put TRUE in[WebMethod(true)]

now is working

thanks

Wednesday, March 21, 2012

Asp dot net ajax drag & drop control question...

I have been looking into drag drop. Most of the example I have come across deal with something like pageflakes. What I would like to do is have two Listbox controls. One has all available choices (AllListBox). The other would have current selected choices (PickedListBox). User would be able to select mutiple rows from either ListBox. When user draged rows from PickedListBox to AllListBox, they would be removed from the PickedListBox. When the user draged rows from the AllListBox to the PickedListBox, it would add rows to the PickedListBox.

Has anyone seen any contorls like this, or better yet tutorials on buildign a contorl like this?

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ReorderList/ReorderList.aspx This is close to what I want. But obviously not close enough.

Thanks,

E-

Look at this

http://www.codeproject.com/dotnet/csdragndrop01.asp