asp:SqlDataSource vs ADO.NET coding with C# - asp.net

I really do not have time to learn new language, in my case asp.net, but would like to start developing website in asp.net. I do not want to use asp:SqlDataSource control. is it ok if i write in codebehind aspx: all database connections and other CRUD operations in ado.net and c#. I already know xhtml, javascript - jquery, css, xml, json, some knowledge in sever-side coding (before php). want to start coding, instead of learning messy asp.net controls. Please advise, or I have to sit and learn all bloody ways of using those asp.net controls?

You do not have to use SqlDataSource control and you can do everything in ado.net and C#.
However, on certain case, you will be able to save quite a bit of coding by using SqlDatasource.

If you feel so bad about ASP.NET controls, why even aspire to use it? While you don't need to use any controls that the framework or third party offers, starting using anything new requires some learning. You don't need to use asp:SqlDataSource to build the data driven ASP.NET website but it seems like you have already shunned all the controls (not just this one) :)
Also, I would recommend looking in to ASP.NET MVC 3.0 if you are just starting. That would be more closer to what you have been doing so far.

Related

So does it mean RAZOR without MVC cannot even do the event handler stuff?

I am new to RAZOR and now I need to trigger an event when users clicked a button, so I can run a lines of code to handle the event.
I don't want to use it with MVC, and I don't want to use JavaScript because I only want to explore the power of RAZOR.
I was surprised when someone told me that the way of event-drive methods has been discarded in the RAZOR, that's alright. But my question is
what is the way to handle/response a click event (in the RAZOR syntax) which is the simplest thing in the ASP.NET Web Form applications?
The reason why I'm asking this question is I found that even the easiest thing like I want to write a fragment of code to response users' input hard to be done(or should I say there is no way to do it) in the RAZOR.
You can take a look the discussion in my previous post.
ASP.NET RAZOR cannot capture the event
I hope there are some guys who can guide me through the first and tough step.
Thanks.
Update:
It seems that there is really no way to handle the user events in any way without the help of MVC framework. Thank you guys for your answers. I'd like to leave this post a few days longer and hopefully I could see someone post something interesting.
Thank you again.
There is no such thing like a click event in Razor.
Event handling is a concept that was used in WinForms. The event model in classic ASP.NET WebForms was an effort to translate the Windows programming model to the web, which, frankly, didn't work very well. A stateful event model and web programming pretty much contradict each other.
If you want to work with events then use classic ASP.NET WebForms. If you want to embrace the web and not work against it, learn ASP.NET MVC, Razor, etc.
Don't try to fit a stateful legacy paradigm on a stateless infrastructure. This is what Microsoft did with WebForms and that is where it should stay.
Razor is only for use with ASP.NET MVC. You can't use it with the WebForms model, though there are some advanced and messy scenarios where some folks mix the two. This isn't what you want.

Conversion from Coldfusion to Asp.net (Drag and Drop Functionality)

I have Coldfusion web application that has a CF query from a database table. This data is displayed in an HTML table with a checkbox beside each data item and an associated picture. There is Jquery functionality on the page so that the items can be re-arranged in the table based on the users preference. After the user finishes with their re-arrangement, it is re-displayed without the checkboxes for sending as an email. Note I did not write this application myself but inherited it...
I need to transfer this functionality to a asp.net C# web application but i am at a crossroads on how to proceed. I've looked at telerik controls and others but none appear to fit the functionality i need. Any solid suggestions?
I'd suggest to handle rendering of the table yourself. If you're using asp.net webforms, this can be done with a custom server control. If you're using asp.net mvc (which I suggest as MVC matches the coldfusion development model a bit closer than webforms), then it's much simpler and you can just do so in the view.
Once you are rendering the grid yourself, then it's simple to apply the jquery functionality on the client-side.
Without more info about what you can or can't do, it's a bit difficult to offer any more guidance. But you did only ask for suggestions :-)
Asp.net doesn't mean you need to use a library control built for .net. jQuery is powerful enough today, and it's not tied to any back end technology.
So, that being said, I would still go with jQuery and back it up with RESTful request using webservices with WebForms or controllers with MVC.
Have a look at this: JQuery Drag and Drop features with ASP.NET

Is there any performance advantage to EntityDataSource over programmatic binding?

I'm working on a heavily data driven ASP.NET web forms application. We're using the Entity Framework 4.1 and I'm normally used to going around databinding all of my controls in the code behind. I've been coming across a lot of examples using the EntityDataSource ASP.NET control and am wondering if there is any advantage to using this control as opposed to binding the data on the code behind?
Thanks, J
I always considered "specialized" data sources risky and against properly layered applications. EntityDataSource, SqlDataSource, LinqDataSource, name it, you provide low-level access details in your declarative code. It feels great for a demo website but could potentially raise severe issues in a large one.
Have you instead considered using the ObjectDataSource? It could provide the best of the two - you provide a clean, declarative binding so there's no binding code required yet the DataProvider (or Repository) class which ultimately provides the data has to be written in C#. From such class you can use any data access technology, EF, Linq, SQL, anything.
See the discussion of EntityDataSource vs. ObjectDataSource in
http://www.asp.net/entity-framework/tutorials/using-the-entity-framework-and-the-objectdatasource-control,-part-1-getting-started

Best way to handle common HTML Controls on ASP.NET

I was wondering, whats the best way to handle common HTML controls in ASP.NET? I mean, ASP.NET server controls generate too much crap inside the code so I rather use common controls.
But how about databind and how to manage those common objects correctly (such as combobox, textbox and so on)?
Don't forget that you can always set runat="server" on any control - that includes standard html form controls such as <input> and <select>, and also other elements like <div>. Anything, really.
This means that you can regain control of the html output in your WebForms pages quite effortlessly - as long as you don't need viewstate or any other more advanced databinding/state managing that ASP.NET normally handles for you.
That said, learning to use the ASP.NET MVC Framework is not a bad idea, since it helps you regain control of much more than just the html output. Generally, creating a page in ASP.NET MVC takes a little more work, since there are no drag-n-drop controls like gridview, textbox or even repeater. Instead, you use html helper methods and regular foreach loops, which means you have to type a lot more code. However, the MVC framework is designed so that you won't have to repeat much code anyway.
If you're concerned about the html markup generated by the WebForms ASP.NET engine, i suggest you take a look at ASP.NET MVC. It's purpose is specifically to give you the control you need over the generated html.
If you don't want to start learning ASP.NET MVC, ASP.NET 4.0 WebForms gives you more flexibility in the generated HTML (such as enabling the ViewState for a specific control only, setting the html id's etc.).
As for the databinding, again if you study MVC in depth and start thinking in terms of action -> result you can gain a lot more control and flexibility.
Later edit: I forgot to mention Razor, the new ViewEngine under development at microsoft. It's currently in beta and only inside WebMatrix, a very stripped down 'getting-started type' development platform for ASP.NET. MVC combined with the very clean code you can write using Razor will be in my opinion an important trend-setter in the web development world.
There's a reason ASP.Net controls generate all that "crap". It's so you can databind and manage those objects correctly. Using standard html controls is useful when you don't need direct databinding or if you have no need to manipulate the control through server-side code.
The best way to handle common HTML controls in ASP.Net is not to handle them directly. By using them to handle data and functionality, you're basically neutering .Net. You might as well go back to classic ASP.

Is the ASP.net GridView control a clever design?

I have been using gridview since a long time. I have a "cant live with you and cant live without you" relationship with it.
The idea of Edits, inserts and deletes from within the grid is great but having to do something like
var sometext = ((TextBox)editRow.FindControl("tbSomeText")).Text;
just seems very un-clever to me. Has anyone comeup with a solution or knows (resource) where you perform CRUD operations + paging and sorting from within the grid and dont have to write ugly code (like above). I am not looking for solutions using DataSource objects since I am not its biggest fan. I will be happy if someone can tell me how to live without GridView in asp.net.
I understand there are AJAX implementations but I am looking for something completely serverside.
I always use repeater control instead of others. Because i feel free with it. I build up the html by myself and can do a lot of thing like paging sorting. But of course you need more effort for the repeater for these kind of functionality.
For CRUD operations, i use jQuery thickbox (modal pop up and iframe).
My choice is Repeater
If you are trying to make a basic CRUD website, have a look at ASP.NET 3.5 Dynamic Data which is a great website to add as a pure data access website with CRUD ability. However, its extremely customizable.
Gridview has its advantages and I used to love it in the .Net 2.0 times about two/three years ago. However, since then there are much better .Net 3.5 controls (like ListView) that give you a better ability to customize content. I'd also have a look at many third party grid tools from (Telerik, Infragistics, ComponentArt, ComponentOne, DevExpress) that have a lot more capability than the inbuilt gridview control.
I despise it, every time I've used it or seen another developer use it, they almost always end up going with something else. I've never once heard any developer I've worked with say "I love GridView".
You can hook up the GridView and DetailsView and use basic SQL scripting or complex business objects along with DetailsView.
I have found DetailsView to be very useful.

Resources