ASP .NET server control vs. HTML control - asp.net

At the moment, in my team, there is a conflict when deciding to use HTML control or ASP .NET server control.
For instance, in order to implement a grid view list that supports reordering, we have two options:
Use HTML controls (ul, ol) and jQuery sortable. By using this approach, we can use the markup and style after slicing PSD and implement it rightaaway. We can fetch data by using jQuery ajax.
Use ASP .NET control like Telerik Grid (http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx). Using this option, we have to change style of server control to match the design.
Considering performance and secutiry, please help me figure out which option is better?
Thanks in advanced.

#batto
telerik grid will wonderful you only not think for only this time . May be in future you need many enchantments in your project at that time you really need to use that feature's . So from my view you use Telerik controls .

For only display purpose Jquery grid is better option, it will increase the performance.

HTML control is a compromise between traditional ASP.NET programming and web control and it has a limited object-oriented interface. We usually use HTML control to have a smooth HTML code that will be generated and sent to the browser
If you want a powerful control, choose web control over HTML control!
It hope it helps you.

I would go with a server control. I would probably just use a
You have the ability to do what ever you want with them. If you want to do sorting using jquery then it should not be too different than how you sort ul's. If needed I can provide a sample. You also have the power of the server. If you tie other events such as add or remove then you will want the server control. Its a bit easier to pass data back and forth.

Related

ASP.NET - improve performance

Is there any reason use standart HTML controls (input type=text,input type=checkbox) instead of asp.net controls ( asp:TextBox, asp:CheckBox) to improve performance?
IMHO this would be a micro optimization. You will gain performance but it won't be noticeable. On the other hand you will loose much of the flexibility offered by the server controls.
You could try to reduce the size of the ViewState by disabling it for controls that don't need it. This will reduce the size of the generated pages and improve performance.
The ASP.NET user controls will all have ViewState associated with them unless you explicitly set
EnableViewState="False"
As such, you will bloat the size of the underlying page if you have a large number of controls. As a general rule, use what meets your needs and nothing more.
Do you need to access the user control in the code-behind?
Do you need the control to maintain value across post-backs etc?
In most cases, it won't make a difference, but it is good to keep your page clean if you don't need these features.
As always with performance optimizations: it depends on the situation. Test it in your project and see if it makes any difference.
Also with .net 4.0 another con of using server controls is gone, since you can set ClientIDMode to Static, which will give you full control over ID's on your controls. Previously using just a standard textbox or button (without viewstate) would still render crazy non-readable ID's because of the way Naming Containers work. Those days are over now though :)
Remember your three options are:
use regular html which can't be referenced on the server.
add runat="server" to your existing html-tags (ie. ) and you'll be able to access it as an HtmlControl.
use the asp.net tags (<asp:* runat="server" />)
The disadvantage of option 3 is that you don't always know what the rendered html-markup will be and you have less control over it. I personally only use option 3 for more advanced controls like , the button () and third party controls. For normal html-markup that I need to reference on the server I prefer option 2.
Regarding performance I would mainly look at the rendered output, how much extra bloat is rendered to the client and such. CPU-time on the server using one or the other approach I would say is secondary compared to the different caching techniques ASP.Net has already.

Which control is best in terms of performance... multi-view or TabContainer in asp.net?

Which control is best in terms of performance... multi-view or TabContainer in asp.net ?
According to your description I would probably don't use any of those two controls. I wouldn't go with tabs as you don't really need to be able to switch between them all the time as is seems. The tabs container uses javascript to enable you to change tab on the client side.
About the multiview. I find it bad practice to have that much different logic in the same place and it will probably give you problems later on. In my opinion and experience it's usually better to split that up in different pages and have one for each thing you want to add/modify (you can have the delete at the modify page and/or in the listings). I would recommend to stay away from the multiview control for tasks like this, as I think that having one page to show multiple pages is usually a bad idea.
As far as i know TabContainer isn't a native control in ASP.NET, you could use TabStrip from microsoft.web.ui.webcontrols, but this is limited to Internet Explorer.
So if you have TabContainer from a third party source, use MultiView which is native to asp.net therefore faster. But everything in ASP.NET eventually renders as basic HTML.
I don't know how they render in HTML.

Any suggestions for a nice ASP.NET Ajax tooltip?

I am looking for a nice tooltip control (with delay) in ASP.NET AJAX. I know there are many nice Javascript libraries out there, but since I am already using ASP.NET AJAX, I may just as well use that.
An "oldie-but-goodie" that I have used many times for tooltips would be overlib It's quite nice, VERY flexible and can be used independent of any particular AJAX platform.
Telerik seems to have the mojo in this area, but since I assume you're looking for free...
The nicest ones appear to be jQuery plugins, like this one:
http://rndnext.blogspot.com/2009/02/jquery-ajax-tooltip.html
There is also this ASP.Net AJAX TooltipExtender:
http://weblogs.asp.net/cjdevos/archive/2008/03/29/asp-net-ajax-tooltipextender.aspx
I was able to make a pretty nice balloon popup using the PopupControlExtender from the ASP.Net AJAX Control Toolkit. You can specify the target control to invoke the popup, the control or div that contains the popup content, and you can also dynamically populate the content using an AJAX callback to a service method.
I recommend:
Pure JavaScript with Ajax capability:
Menucool Tooltip
ASP.NET version, with Ajax Load On Demand:
Menubasic Tooltip
If you don't need the Ajax feature, Menucool has a very easy-to-use CSS tooltip either.
One option is WZ_Tooltip. Most tooltips are basic javascript; you should not expect to find much in the way of .NET integrated tooltips, since there is not much reason to use it rather than just using a javascript.

Add a new item to html-select list without leaving the page. How?

I've always wondered what is the best way to add a new item to html-select in a website.
Yes, this may sound silly but it is a great problem from the usability perspective. I don't want the user to be taken to a new page every time they need to add new item to a html-select.
I like the way Google Reader and Gmail handle this problem in there "add folder" and "add label" functionality. I would like to mimic that but i have no clue how they did that.
I'm using jQuery, so any reference to plugins, code examples or tutorials are welcome.
I would like it to be as modular as possible so i can reuse it anywhere.
I'm using ASP.NET 3.5 web-forms, Microsoft Access 2003, jQuery, IIS 5 and Win XP Professional as web server.
Thanks.
there's a jquery select plugin that might help you with this. I've manipulated select lists client side and had no problem with subsequent form-submits but you'd need to do some experiments w asp.net
The standard technique of doing this is called ajax, which basically means replacing only parts of the page. JQuery ajax and maybe a tutorial should get you going.
A common mistake for this scenario is to add the item on client (using jQuery or plain javascript). It may look that it works until the next post-back. Unfortunately the Asp.NET post-back model does not allow to alter the controls contents on client side only. So basicaly there are two choices:
Use ajax (the simplest would be to
use an UpdatePanel)
Make a normal
postback to add the item (simple and
fast to code, if performance is not
an issue - for intranet applications
for example)

Autocomplete Textbox on Gridview editing

How do you implement autocomplete on ASP.Net Gridview? Can anyone point me where to go to achieve this? I'm willing to use non-.Net ajax controls if that what it takes.
You will need to utilise an AJAX framework (JQuery is one i often recommend) which will provide the functionality to display the drop down box. You will then need to create a separate page (or web service) to return all the possible values to display in the auto-complete drop down.
To save on performance i recommend only initiating the auto-complete once the user has typed in 2 or 3 letters. These can then be passed by the JavaScript to the backed to proivde values to show in the drop down list.
The back end can communicate with the JavaScript using either simple CSV, JSON, XML Web service etc. See http://www.pengoworks.com/workshop/jquery/autocomplete.htm for examples.
The AJAX Control Toolkit provides an autocomplete but requires a web service to work. You could always write your own asmx if there isn't one you can use.
Otherwise, there are all sorts of JS and jQuery examples:
http://www.javascript-examples.com/autocomplete-demo/
Scriptaculous has a nice autocomplete component. It is built on prototype.js.
I've used it to display an autocomplete list with formatted text and images etc. In that sense I think it is more flexible than the ASP.NET AJAX implementation.
Documentation http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleter
Download http://script.aculo.us/downloads

Resources