I want to programmatically create a table when the user clicks on a button. I have made a program in C# asp.net witch adds a HtmlTable inside a PlaceHolder (that is inside a UpdatePanel) when the action is performed. The problem is that the operation taks a lot of time (there is no database involved) and I want the table to be constructed before postback (I mean to add the rows with the data in time, when it was processed).
I don't know how this is done, or if it is posible. I don't know Ajax.
I can provide more details on the problem.
Thank you.
You can do that using jQuery, its quite easy and good to learn.
Super Simple
http://blogs.microsoft.co.il/blogs/linqed/archive/2009/03/04/generating-html-tables-with-jquery.aspx
Related
I have repeater control in which i am binding data from sql server database, Now i have number of records showing on my page but i want that i can filter my records according to dropdown selected. I need 4-5 dropdowns control thats depend on my need and i don't want my page to refresh while filtering.
Below is the example, this website using checkboxes too but i need only dropdowns...
http://www.phonearena.com/phones/full#/phones/full/
Give me any idea how to start, i think ajax is the thing i need. Suggest some examples if you have.
Ajax is the right solution.
Personally i suggest you jquerytemplate and ajax call few row code to achive your goal you may find more info here Load JSON data using the dropdown menu and refresh the div area with the new results in a web site
It is a good point to start and you can make more stuff with this logic :) really simple and fluid code :)
I would suggest you to use a client-side framework (so in JavaScript) like AngularJS, BackboneJS or KnockoutJS. They all provide ways to work with collections in JavaScript (like filtering in this case). You won't need Ajax excepted for the first load or if you want to do some paging. And because it's all client-side it will be far more fluid than re-downloading at every criteria change.
I've seen multiple websites on the web where they allow you to manipulate data. (i.e. Insert records, delete records, edit records).
The cool thing I've noticed is that when you click remove button, the item removes instantly from the grid. and then it asynchronously goes to a database and removes record from there without bothering a user.
For example in a regular asp.net application if you're using gridview you need to wait until database operation is complete, because gridview is a databound control. If you use update panel you still see item in grid until DataBind event fires again.
Question: is there any js/.net library that will allow me to add such a functionality to the project out of the box?
Maybe you want to use WebMethod on server side + Ajax calls on client side (using jQuery for example).
You can you Client Side Grid Like JQGrid. http://www.trirand.com/blog/jqgrid/jqgrid.html. For loading and editing data you can use Web method or web Services. You can also use ASP.net MVC .
Yes you can do.You have web method that read your data from your source such as database.
You can call this method using Ajax and you can bind ajax response to gridview
Here is example Link
I wrote a page which user can input a name and get some infos from the database. In the .cs file I got the texts from the database and assigned them to the labels and in the debugging mode, the labels did change their texts. BUT I don't know how to update them in the same page. I used some ways to update the page, but it updated the whole page and display nothing in the labels.
How can I achieve this function?
I google it and found the AJAX is a good way, but it's an emergency i have no time to learn AJAX?
does someone have good idea to help me solve it?
Thanks a lot!
What you're talking about is a postback. When the page posts back to the server, the page is refreshed.
If you want to set the labels and avoid losing the data with a postback, you can do so through an ajax call in your JavaScript code, you can set hidden fields or you can set the values in the Session object (not the best idea). There are numerous ways around this; you just have to pick one.
Do some reading on ajax (it's not as hard as you think). You can call the server through ajax, which will get the data from the Db and return it to your JavaScript as JSON. You can then use that to fill your labels.
You may want to look into an UpdatePanel as well. They aren't the fastest solution available, but they are very easy to implement.
I am making some changes to already existing ASP.NET MVC 1 app where there is a form with a dropdown list that has all 50 states hard coded into the HTML. After filling out the form the user can later go back and edit their information. I want to make it so that on the edit screen the value that is already in the DB gets the "selected" attribute for the state. The only way I can think to do this is to build the html on the server and send it down to the view, is there a better practice?
No, View is the only place where you should generate the markup.
My suggestion is to write a JavaScript snippet like this:
$(function(){
$('#dropDownId').val(#Model.SelectedValue);
});
It's effective, easy, maintainable, and of course, fast.
In my site, I'm using update panel in the master page. Half of my web page will retrieve the data from the database in dynamic. As, my update panel is in master page(with ajax loader), it is taking much time for every event. Is there any other advanced method to get the data from the database instead of using update panel.. Or any other idea instead of this?
I think you need to profile to see where the bottleneck is; I expect you have unnecessary code going on in your aspx that isn't really needed for the UpdatePanel.
Personally, I wouldn't use UpdatePanel now; I'd use a simple (but separate) page (or route, if using MVC) that just does the code needed for this work, and use jQuery to load it.
I think you want to load your web page from database table which contains html. If it is so then the best idea would be to create controls for headers/ footers or repeated sections and use caching which would reduce the load time of your web pages.
You could easily cache your controls. You can check here http://msdn.microsoft.com/en-us/library/aa478965.aspx
Happy coding