textbox autocomplete - c#

how do i make an autocomplete textbox in asp?
but i need to get the autocomplete data by querying the database.
I dont really know how to explain this, sory if theres not enough detail.
i cant use ajax, because i think i will have compability issues with my old app.
so im thinking of doing this using java script. or is there a way to do this by using .net?
im using C# for codebehind. thanks

It's going to be a lot of effort without using some third party autocomplete I think - not sure what you mean by 'I can't use ajax', but how about using the ASP.NET AJAX autocomplete control, setting the ServiceMethod property to a static Page Method in your code behind? That keeps it contained within your page at least.
The Page Method can go off to your database, and return a String[] of results.
If you decide to use it, you'll need to set the EnablePageMethods property to true in the <asp:ScriptManager> control.

AJAX is JavaScript. It's JavaScript using the XMLHttpRequest object to make the asynchronous request. Here's an article about it and ASP.NET.
If you want to know more about AJAX, (Asynchronous JavaScript and XML), I'd check out Wikipedia first. If you want books on it, there are a ton. I recommend Programming ASP.NET AJAX by Christian Wenz (O'Reilly And Associates).

if you dont want to uses ajax library, try jquery
there are many plugin autocomplete or suggest textbox for jquery
try this one
http://www.vulgarisoip.com/2007/08/06/jquerysuggest-11/

The ASP.NET AJAX framework works for ASP.NET 2.0 & above. As such it will not work in Visual Studio 2003 environment.
Anthem.NET is a free, cross-browser AJAX toolkit/framework for the ASP.NET development environment that works with both ASP.NET 1.1 and 2.0 -
http://sourceforge.net/projects/anthem-dot-net
For your autocomplete requirement, you can consider using the jQuery Autocomplete Plugin
It requires very less programming. Check the demo & code sample here - http://docs.jquery.com/Plugins/Autocomplete
It's autocomplete() method takes a URL or array to populate your autocompletion list. You can pass the URL of the page that fetches the results from the database directly.

Related

Manipulating a webpage by its source

I have googled this with a couple of differing terms and I could not find my solution. What I want to do is to manipulate a webpage by editing its source, for example removing a part from the code maybe a div or so. I know how to get the source of a webpage and know how to change the code but I have no idea how to manipulate the page instantly, by for example removing an element.
Your help would be appreciated!
If you want to manipulate client code (HTML) what you need is Ajax.
You can use JQuery javascript library to manipulate html of a page adding, editing and removing html tags, scripts, etc.
Here you can find a decent tutorial as a start point.
If you want to manipulate server code (C# codebehind) what you need is creating a web project in visual studio (ASP.NET Web Application)
EDIT: As commented by #CSharpened both solutions are not mutual exclusive. You can have an ASP.NET Web application that uses Ajax to manipulate UI. In fact lot of people does that.
I would consider using AJAX. You can use either javascript or jquery coupled with html, asp.net and C# to achieve the results you are after.
For simple editing like removing divs or collapsing menus etc simple Javascript or jquery will suffice. However changing the coding of the page requires you to use AJAX or similar.

Creating a Chatbox with AJAX, HTML and C#?

I am using the Nancy Web Framework in my C# Console Application to basically create a Web Administration panel for my software. I have opted to use the Spark View Engine, as it is basically just HTML. I basically want to create a chatbox, except pull the data written to my application's console every X seconds and display it in a box instead.
I have very little experience with JQuery and AJAX, but they aren't overly complicated from the examples I have seen. The issue I am running into is that ALL of the chatbox and shoutbox examples use PHP.
I basically just need something like this...
The only difference is I need to pull the information from my application instead. I can use basic C# methods inside of the HTML (and probably inside of javascript but I haven't tried this). What would be the best way to do this, and are there any examples floating around that don't use PHP?
This was completed using AJAX and JSON.
Well, to use HTML for styling inside some PC program is just not wise. It has much better UI engines, though. But for your information here is nice jQuery shoutbox tutorial, but well, you only need to handle data input and output with C#, so actually I see no problems. The engine which you are using should have some kind of data stream, or requests handler (bla://program/???)

make jquery ajax calls to asp.net page

How do I go about making true ajax requests to an asp.net page? (Not update panels). I read this tutorial but couldn't get it working. Is there a better approach? Or should this work?
http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/
The standard today is using JSON to get the job done. That means you'll be using JavaScript, and when you're using JavaScript jQuery is your friend.
Here's some example code that uses AJAX, jQuery, and a .NET Web Service. Learn it, love it, live it.
Try PageMethods. It will be easier. You're living in a .NET world, use the .NET tools.
Here's a page to get you started.
http://aspalliance.com/1922

jquery and ASP.Net AJAX framework

I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net. I am new to jQuery and ASP.Net AJAX framework. Suppose I need to use jQuery function (e.g. from jquery-1.3.2.js). I want to confirm that jQuery and ASP.Net AJAX framework are totally two different things, no dependencies?
So, no need to install and configure ASP.Net AJAX framework in order to use jQuery function?
thanks in advance,
George
Yes you are correct. You don't need both to function. You can find information on the AJAX toolkit here. You might also find JqueryUI quite useful. I'm quite new to Jquery as well and found JqueryUI to be quite a time saver. If you want, you can also let Google host Jquery and/or JqueryUI for you, so your bandwidth doesn't get taken up (Info here). Just to add, if you want intellisense with your Jquery code, this blog shows you how to setup VS2008 to do so.

Implementing UpdatePanel manually

I was reading an article that shows how bad CodePlex uses UpdatePanels and how nice is StackOverflow on this matter when, for example, a user upvotes an answer/question.
I wonder if someone can point a tutorial on how to do such action.
I know some points:
Create a Web Service that gets the action value and ouputs a JSON string
Build the javascript inside <ajax:ScripManager> control to replace the correct value on the page with the new value
But, even in the first I have difficulties, I can send a JSON string, but it will always be surrounded with XML information!
Can anyone (or maybe Jeff) point to a nice "how-to" since scratch? Thank you.
Well, I doubt StackOverflow uses UpdatePanel - more likely it uses jQuery / load to simply update a div, using ASP.NET MVC as the source (rather than ASP.NET vanilla, which has a more complex page cycle).
With this approach, it is trivial... the jQuery examples tab largely says it all.
Re returning the Json - that is simply return Json(obj); from the controller in ASP.NET MVC - but personally I'd return the html (simpler).
Before you dismiss the UpdatePanel I suggest you have a read of this post I did - http://www.aaron-powell.com/blog/august-2008/optimising-updatepanels.aspx. It looks at how to optimise UpdatePanels and it can lead to some performance increases if done well.
I also did a post - http://www.aaron-powell.com/blog/august-2008/paging-data-client-side.aspx which looks at doing client-side templating with jQuery and MS AJAX. I look at how to read a web service with JavaScript and if you download the sample you'll see how to send data client-side to a web service.
But this video cast on the ASP.NET website may also be of use - http://www.asp.net/learn/ajax-videos/video-82.aspx. It's on how to extend web services for script service capabilities.

Categories

Resources