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

Wednesday, March 28, 2012

VERY new to asp.net AJAX: Enabling controls based on slection from AutoComplete control

I've been reading all day and I'm not finding the solution to my requirement.

I'm developing a form to enter "lead" information, part of the lead data is the name of their Dr. We maintain a MySql DB with leads and Drs information.

When a user is entering a new lead and they type the last name of the Dr I have a AutoCompleteExtension fetching Dr.s that match the last name. When/if the user selects a Dr. from the list I want to DISABLE the other Dr. related fields (FName, address, etc) and insert the data from the selected Dr. If there is no match found, the user will enter the details for the Dr. (new record).

The main issue I'm struggling with is how to respond (client or server) to the user making a selection from the AutoComplete list and enable/disable and populate the related fields. For example, the user picks a Dr. from the list, I then want to disable all the Dr. detail related fields and set the values with the record from the database.

I'm not sure how I will accomplish this yet, I imagine I would need to set those values from the server side and it would in turn use AJAX to push the values down to the client?

If anyone could give me a little guidance I would really appreciate it, I just need a jump start to get this thing going.

Thanks for reading,
Steve


If you're Textbox that has the AutoComplete extention on it loses focus, why not use the onBlur event to check to see if they used your AutoComplete (which would have text in that textbox). If they did use the AutoComplete, then use JavaScript to disable the other textboxes.


You could use the ItemSelected event of the AutoComplete extender in the client and as RTernier says use JavaScript to disable the other textboxes, you could call a webservice to obtain the remaining information of the doctor, check: http://www.asp.net/ajax/documentation/live/tutorials/ExposingWebServicesToAJAXTutorial.aspx
http://www.asp.net/ajax/documentation/live/tutorials/EmbedScriptFile.aspx For information on using WebServices. You could also use an UpdatePanel, I guess you could call a partial post back from the ItemSelected event, although I'm not an expert in UpdatePanel, but I think it would work (personally I like the webservice way better, but it's a matter of choice).

virtual earth makes autocomplete half transparent in firefox

hi, i just spent almost a day on this. any help/advices would really be appreciated.

i attempted to put 2 of the coolest asp.net tools to work together on the same page, but found that it doesn't work for firefox.

i have the autocomplete in "SampleWebSite" working, but as soon as i added the below VE js reference, the auto-complete list went half-transparent and went behind the map area.

<script language="javascript" src="http://pics.10026.com/?src=http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>

so, i provided my own div element with a very high z-index, but it's still half transparent. it only happens in firefox.

<div id="completingName" style="z-index:999999;"></div>

see this, http://208.75.249.11/map.jpg

thank you very much.

Are you using the latest version of the Toolkit? What is the behavior in other browsers? What is the z-index of the flyout and the ve control?


i believe i am using the latest version of asp.net ajax toolkit because i just downloaded it this morning. virtual earth is 5.0.

other IE is fine, no problem. i just have problem with firefox (http://208.75.249.11/map.jpg), don't know about others.

thank you very much.


Could you please provide the repro? Thanks.


Not sure if this helps, but I had a transparency problem with firefox too. I used the exact styles from the AutoComplete sample and got the following problems in Firefox:

1) the items in the list were all indented by about 20 pixels (whereas in IE all the items in the list were left-aligned with the start of the text box.)

2) Textboxes underneath the autocomplete list were showing through the list, they weren't being covered when the autocomplete list appeared.

I'm not great with CSS, but a colleague was able to fix the issue by making the following CSS changes (the original styles were copied from the Autocomplete sample on this site):

in class ".autocomplete_completionListElement"

change "background-color:inherit;" to "background-color : #fff;"

and add a new style to the class:

"padding:0;"

So you end up with:

.autocomplete_completionListElement
{
visibility : hidden;
margin : 0px!important;
background-color : #fff;
color : windowtext;
border : buttonshadow;
border-width : 1px;
border-style : solid;
cursor : 'default';
overflow : auto;
height : 200px;
text-align : left;
list-style-type : none;
padding:0;
}

Hope this helps,

Ollie

Monday, March 26, 2012

VS 2008 RTM AJAX Toolkit 3.5 Autocomplete extender has issues

I just installed VS 2008 RTM and the autocomplete has issues. I created a new page added the scriptmanager and set it up to enablepagemethod so that I could use my local database to supply the autocomplete strings.

I dropped a textbox on the page then I dropped the extender onto the control. It appeared in the properties list of the textbox as expected. I changed some properties and set the ServiceMethod.

The extender did not alter the source. All the property changes were lost. I tied this several times and always the same result. The properties could be changed in the properties window but these are not updated in the source aspx page. So when you switch to source view from design the changes are simply lost.

For those who would like to implement a pagemethod rather than a webservice call, I found two good sources:

http://allwrong.wordpress.com/2007/03/13/ms-ajax-autocomplete-extender-using-a-page-method/

http://fredrik.nsquared2.com/viewpost.aspx?PostID=393

From my codebehind page:
<* The autocomplete extender is designed to use a web service to supply the items for the list box. Sometimes this
* is certainly an over-kill or the data may be accessable directly from the application's database connection. A
* web service is an un-needed layer for these times. So here is how to call a "page method" to supply that data.
*
* 1 - add: using System.Web.Services;
* 2 - In the html, modify the ScriptManager with the EnablePageMethods set to true.
* ex: <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"></asp:ScriptManager>
* 3 - add a declaration for the page method: [WebMethod]
* 4 - add: public static string[] methodNameHERE(string prefixText, int count)
*
*/

///<summary>
/// ServiceMethod - The method to be called. The signature of this method must match EXACTLY as below.
///</summary>
///<param name="prefixText"></param>
///<param name="count"></param>
///<returns>string array</returns>
[WebMethod]
publicstaticstring[] getCompanyNames(string prefixText,int count)
{
bbCMScore bb =newbbCMScore();
string[] s = bb.getGroupingUsingUserCompanyNameSource(prefixText, count).ToArray();
return s;
}

The ASPX code looks like this:

<asp:TextBoxID="tbGrouping"runat="server"></asp:TextBox>
<cc1:AutoCompleteExtenderID="tbGrouping_AutoCompleteExtender"runat="server"EnableCaching="true" CompletionSetCount="20" CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem"CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" MinimumPrefixLength="2" TargetControlID="tbGrouping" ServiceMethod="getCompanyNames">
</cc1:AutoCompleteExtender>

The above works as it should. The problem is the properties are not updating. This causes VS 2008 RTM to error with a "souce code not available" error which certainly doesn't point to the real problem. You thought you set the properties and really they were not set.

Larry Aultman

Hi Larry,

Your problem is such weird issue. Can you modify or add extra code to your page? We suggest that you should check which version of AJAX Control Toolkit that you are using now. Please upgrade it to V11119. Also, you should check the .NET Framework version and AJAX Control Toolkit version. So do the web.config settings. AJAX Control Toolkit are divided into two versions for supporting .NET Framework 2.0 and 3.5.

Best regards,

Jonathan


Jonathan,

During the upgrade to RTM from Beta 2, I uninstalled everything Beta2. I uninstalled all projects from my machine, and deleted all traces of my development environment. I installed the RTM, downloaded the latest versions of AJAX toolkit. I created an new project.

I did verify that all my versions are for 3.5. My work around is to just not use the properties window for the control. However this control has other isses that are show-stoppers. I have commented on them in this forum under the "onClientItemSelected" event that will not fire. I can make it autocomplete but I can't get an event fired so it isn't much use to me. Thus for the moment I can't use it in production.

Thanks for the reply. I hope that someone is able to find the problem as it would be useful to users.

Larry Aultman


Hi Larry,

wph101larrya:

My work around is to just not use the properties window for the control.

Only for AJAX Contol Toolkit's Controls or all the Controls?

If the former, please do this and have a test.

We suggest that you should download a sample fromhttp://www.asp.net/learn/ajax-videos/ and have a test. Please make sure Javascript is not forbidded in you machine.

Best regards,

Jonathan