New row in asp:repeater by java script - javascript

In my aspx page I have repeater to show list something, I want to add new row and show it in repeater without postback. I will send date soon. I don't want to use AJAX
How to add row to asp:repeater by JavaScript?

The best bet is inpect the code using a tool like firebug retrieve the html for the row, and recreate that using javascript and attach it to the DOM. Dirty but doable. Using something like jquery will make your work easier.
I know you dont want to use AJAX but the cleanest method would be to use an UpdatePanel and do is on the server side using a partial postabck

The repeater just generates repeating html so it's definitely possible to insert new html by using javascript. As #mellamokb mentions those changes won't be visible on the server side.
It's generally a bad idea to mix client and server side rendering with ASP.NET Webforms.
In the case of a list of some kind being dependent on e.g. a combobox it's often a better idea to render lists for all options in the ASPX code. Then use javascript to hide every list except the currently active one.

Related

Is it good practice to make your navigation buttons form buttons?

I want to create a classes pages. The way i want to approach is that based on what class you have chosen, the class template will populate based with content based on the class that you've chosen. I want to create one class template and let the rest of the content come from the database, the only way to do this is by making the navigating button a form button am I right or is there a more efficient way? I am using python django for server side
ie
<button type="submit" value="math">
This would imply that your page will reload every time you click, a more elegant approach would be to use some JavaScript and some AJAX like this onclick="someFunction()" and after that you use some ajax to populate your page.

Using Javascript with Asp.net for ListBox

I want to use ClientSide Javascript for listbox, it should take values from database table when the page is loaded first time OR load the specific table in javascript,
Right Now, all the values are coming from database, if I select "StandardM1(CA)"
it brings all the values from "food_menu" table.
I want to do the the same thing with client-side javascript in order to save time and server requests, so that the application runs faster.
Can some one please guide me?
Faheem use array in it and try to do the coding right on the save button. its the save button that is creating problems

javascript or ajax actionlink

I am working with mvc4 and new to working with it. I have a question around the Ajax ActionLink.
I have a long list of products, with each, there is an add to bag button. In the past I would use jquery to bind a click event to this button and then use javascript to make a server side request to a controller action.
I want all interaction to not cause a full page postback.
I am wondering is it best to follow my approach with javascript or use the Ajax ActionLink? What are the pros and cons of either approach?
Both are same.
Ajax ActionLink : less to write, works with conjuction Jquery un-obtrusive. Not much control on the markup.
HtML Link + Jquery Ajax call : will you give full control on the click event, you can add extra options to it.

jgGrid customized add new form

When I open a blank form to add new row to the grid, I need some fields on the form to be dynamically updated by going to the database to search for data if I change a field on the form.
I found the code in the javascript to create a form for adding new row, may I change it to read from an external file (like an asp, php page) or is there any way to do it properly??
You must use ajax to make calls to proper functions and change your html according to response data.
More info about ajax
Jquery supports ajax and have many nice features for ajax usage and let you have nice page alteration based on html DOM. So i advice you to have a look at it...

Can I get some recommendations for list control with image buttons?

I'm looking for recommendations how to implement a list of items shown as images that the user can toggle on/off on the client-side, which then can be tracked and saved on the server side.
I looked at the possibly using the asp.net list view control but as far as I can tell the client side API isn't that great so I'd need to write a significant amount of client side code.
Any suggestions on a way to do it better?
From the jQuery side, I'm a big fan of the jQuery UI model, where the UI is entirely separate from the back end. Not everyone agrees with this (cough JSF cough) but if that's the route you're willing to go, it wouldn't be that much work. What I would do:
have asp.net render out a multi-select INPUT field.
hide it with CSS
via jQuery parse out the value/text pairs (which would be value/URL)
render out the HTML you want based on the value/URLs (Such as DIVs with an IMG in each).
apply a click event to each DIV that, in turn, updates the selected value(s) of your INPUT field.
Now, the reason I like this method is it keeps the server-side code simple. And as a front-end dev, the simpler I can keep it for the back end team, the happier they seem to be.
The problem I've found with most commercial .net components is the fact that they spit out their own custom UI layer that is often full of convoluted JS and overly-complicated markup--wich makes them rather inflexible from a custom UI perspective.
Telerik has an ASP.NET AJAX control called "ListView" that allows a user to select multiple images (in the URL sample click the items in the bottom of the two panels). Because it is AJAX the selections are syncing Live with the server, however this could work if a List or similar object in the ASP.NET page was doing a List.Add() or List.Remove() as items are added and removed.
http://demos.telerik.com/aspnet-ajax/listview/examples/selecting/defaultcs.aspx

Categories

Resources