Best ASP.NET dynamic user control load approach - javascript

I have a food menu ASP.NET Web app. I use a datagrid to display the menu items. When the user clicks an item in the grid, a user control opens up below the item to allow the user to enter item details and add the item to an order. The item detail user control in turn contains several user controls with RadioButtonLists, DataLists and TextBoxes. The RadioButtonLists and DataLists are populated from a database. The user should be able to open and close several items at a time, like Windows Browser with sub-folders.
I've tried doing this with strait ASP.NET AJAX using ScriptManger, etc.. I set the item detail user control Visible property to True, and populate the list controls during the OnPreRender event. This is slow and sort of complicated because of the ASP.NET page/control life cycle.
I've been looking into using JQuery requests to ASHX files or Page Methods on the server to generate the item detail controls with maybe RenderControl and sending the generated HTML back to JQuery.
Questions:
Am I on the right track?
Would this sort of approach work for rendering and sending back HTML that may be complex and long?
Would JQuery requests be more efficient than my current approach?
Can anybody point me in the right direction for references and/or examples?
Thanks for the bandwidth.

I found a lot of help that led to my solution at:
http://weblogs.asp.net/sanjeevagarwal/archive/2008/07/22/Dynamically-create-ASP.NET-user-control-using-ASP.NET-Ajax-and-Web-Service.aspx

Related

How to save selection state in multipage results view?

I am trying to figure out how I can save selection state in a web app. To be more specific I am making some query interface that queries a mongo backend. The results are are rendered in a image gird type view with checkboxes on each image and a download button to download selected images. Now, I am anticipating dealing with a lot of results for a given search. To handle this I am going to use paging. I am wondering how I would even save the selection state as I am flipping through paged results. I am totally new so if anyone can so much as provide an answer with some supporting information I can look into; that would be great.
Use AJAX to fetch the results on the next pages and append it into a separate section in the page rather than navigating away from the first page. This way the selected results are maintained as they are. You may need to do some calculation around your pagination and some toggling logic to show/hide divs when the pagers are clicked.
Useful link you could use (maybe ignoring the PHP/MySQL parts): http://www.sitepoint.com/pagination-jquery-ajax-php/

block web parts in sharepoint from certain users

I'm looking to see if it's possible to block certain data in web parts from loading or showing for certain users?
I have a SharePoint page that was written in asp.net and JavaScript. What i have is a page that runs several queries and displays them as separate web parts. I would like to be able to block certain web parts that show financial information to only show for the managers group.
I am able to just hide the web part from showing at all but that isn't necessarily helpful.
any help at all would be greatly appreciated.
thank you!
I would create a hidden div that contains the users access level (or I guess you could use an array to hold / define unique users who should or shouldnt be able to to 'see' the parts)... then just write a function that reads the hidden field and based on the user who is viewing the page, show or hide the content based on the id of the web content element / part.
I would probably try to do this on the server side though before the content in question is sent to the dom.
good luck
A possible solution could be is to hide the webparts using audiences. Edit the page, edit the webpart, navigate to the properties, in the Advanced section you'll find something called "Target Audiences". Either use an existing audience (which you can create in the user profile service application) or enter a SharePoint group name (like the site members, of something alike 'managers'). Members of that group/audience will see the webpart then. Other users will not see the webpart.
Notice that this is not a security measurement. E.g. it's just preventing the rendering of the webpart, it's not preventing users from accessing the data if they know where it comes from.
Read more here: http://office.microsoft.com/en-us/sharepoint-server-help/target-content-to-specific-audiences-HA010169053.aspx

How to load items on page only when page is scrolled down?

I'm new to ASP Web Pages. Trying to build a shopping like website. I have created Databases first, Now what I want is to display "some" items of users' interest only so as to keep page light. Later when user scrolls down, next "x" number of items are fetched from Database and are shown to the user. Its like something you can see on myntra.com, but definitely not like on ebay.com where number of items are fixed on one page. I know it will use javascript but can't figure out the correct timings of firing events and adding more items to page?? I saw on stackoverflow itself about scroll down event, but I think that was related to a particular ID on a page.
Here's how it's done on the client side:
http://www.youtube.com/watch?v=eziREnZPml4
In addition to that, you will need some server-side logic that will track what has been sent already, when a request for more contents comes in. One way you could achieve that is to always read the items in the same order, and have the browser send the "latest" item that it has with each subsequent request.

Make javascript mandatory in web application?

I am building a web application that will have a fair bit of forms. The html forms are generated using php.
One of the things I came across is this:
I have a drop down box for the user to select his country. Once he selects the country, a call is made to the server to fetch a list of states within that country and populate it in a drop down box.
Initially, I thought I could provide 2 options:
An enhanced jquery version where ajax is used to fetch the states and the populate it in a drop down.
Where javascript is not availiable, the whole page is submitted to the server and then rerendered with the new states in the drop down.
However, onChange() requires javascript. So if someone where to visit the form without javascript enabled, there's no way we can deal with the second option, since javascript is required to submit a form using onChange().
What are some ways to deal with this? My only solution at the moment is to just make javascript mandatory. Users without javascript enabled will see a message saying that the page will not work properly.
Some sites:
Hotmail.com - Refuses to show anything except a "javascript is required message"
Facebook.com - Tells us we should use the mobile version of the site.
Google Maps - Does not work. No message to say javascript is required.
Gmail - Falls back to basic html.
Google account - Does not work. No message to say javascript is required.
Is it acceptable to require users to have javascript enabled at the current state of the web (august 2011)?
Just came across this possible solution:
http://cita.disability.uiuc.edu/html-best-practices/auto/onchange.php
I could perhaps add a button which the user can use to select their country. This should allow us to reload and render the form with the states drop down without any javascript.
You can provide a drop-down of states and tell the user to leave it blank if not applicable. If JavaScript is enabled, it can remove the drop-down until a country where it is applicable is selected.
No, it is not acceptable to require JavaScript; many security-conscious users use NoScript, for example, and would prefer not to turn it off.
By default you should load all possible values into the second dropdown, then clear them out on page load with Javascript. That way people without Javascript enabled can still choose the correct option.
I'm guaranteed to take flak for this, but whether you support no-JS or not should be your call. If you think your userbase is likely to have a sizeable portion of people who disable JS, then you should give them a site that works, but not optimally. If you think most of them will be running with "normal" (air quotes are important there) browsers, then you may consider dropping support for no-JS users.
I am NOT a professional developer, so take my input accordingly. Here are my observations:
I support a website for a wedding cake vendor. Upon observing the competition, all the more appealing sites are embellished (tastefully) with slideshows, dropdowns, animations, interactive form validation, etc.
When scouting for methods to incorporate these features into our site, I found that mostly every classy method was based in javascript.
Figuring it was better to present ourselves as the classy act we are (humble smile), I have decided to require users to have javascript enabled. We've been up for 7 years, and I have not received any complaints. All work on mobile devices.
A compromise option is to start with your State drop-down populated with the states of whatever country your business is in, e.g., all US states, with an extra option (preferably at the top of the list) that says "Other, non-[yourcountrynamehere]". Next to the State drop-down have a text input where the user can type the name of their state if it's not in the list. If JavaScript is enabled then on document-ready you can hide the text input and go with your Ajax solution. Without JavaScript the user has a fully functional page that doesn't even need a reload.
What I ended up doing is to add a button beside the drop down that says "select country". Users without javascript will see this button. Upon clicking it, the page will reload with the list of states rendered.
For users without javascript, this button is hidden, and selecting a country will automatically render a new drop down containing the relevant states.

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