design - best (easiest) way to add dynamic content to a asp.net webforms application -


i working on asp.net webforms app, , have create 'dynamic order lines' is: select product , quantity, , amount calculated. visualize: on 1 'line', forst product dropdown, next quantity textbox , next amount label.

then click 'add product', , 'line' added product dropdown, quantity textbox , amount label.

so can click add , add , add....

now thinking how implement that, , came 2 choises:

'add html client side' , 'add user control server side'

the first looks more fancy of course, have create server side code generate lines again, when user says 'go' after validation have warn user example amount on credit or quantity high. 'client side' added html, , have reproduce in code behind, right?

on other hand (add user control server side), have create new user control on 'and product' postback, might easier in beginning because it's strong typed, , client side (jquery / javascript) isn't?

i'm looking forward opinions.

and 1 more thing: there possibility (they not sure yet) functionality wrapped within 'section', address box , call order. , then: user can add 'section' multiple times, can create multiple orders in 1 page, have create multiple sections order, , within order have possibility add product.

it looks hard client side, generating id's?

using hidden field json

adding additional fields feels wrong add on server-side.

  1. it takes long add additional one
  2. you may have scroll position issues
  3. and it's such simple , quick process on client.

i suggest put hidden field on page , save fields' data json string in it. on server side can use javascriptserializer class deserialize json , data generated on client strong type object instance better!

but otherwise... input fields add using javascript not have server side view state, can still access values in request.form["somename"] means can give them whatever id/name long they're unique.

some code

i'd add input fields css class dynamic make easier collect of them json generation. code generate json object should serielized hidden field:

$(".dynamic:input").live("blur", function(e)) {     var jsondata = $(".dynamic:input").serializearray();     // use lib or plugin save hidden input field } 

there many libraries jquery plugins stringify jsondata object string. this stackoverflow question has many possibilities. check answers.

asp.net ajax not improvement

using asp.net ajax library suggested brian brinley make things they're generated on client still slow since normal server request meaning whole view state transferred server , whole page cycle processed there before returning. library isn't option serious complex projects , suppose majority agree.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -