I'm trying to write a system that will produce HTML snippets for users dependant on what they choose from a number of options.
Each user will have a unique ID (already in SQL DB) which links to the options they are allowed to select from.
Does anyone have any ideas how I should go about doing this? The pages are ASP.NET C# but I'd prefer to use HTML, JQuery & Javascript for the UI. However I do need to pull the relevant info from SQL.
Thanks for any replies!
No problem using html & jquery for the ui.
You can just create a the basic site layout in asp and take advantage of masterpages to limit duplicating your work with any cross page content.
You can add form controls to the pages in asp but don't use server side controls.
Use the regular html form controls so you don't get any post back on user input.
Server side controls will look like this:
<input type=text runat=server ...
the "runat=server" in the tag will cause a post back on the server. Not something you will want if you're planning on using javascript for the ui.
Once your page is set up then you can attach your javascript/jquery to those html form controls and use ajax to query the db to limit the user selections.
With response to your comments:
So if user logs onto system and sees a number of logo and text variations they can download, I would use ajax to query which combinations the user has access to and with that info, dynamically create the download button/link using javascript.
That way no redirect/page refresh etc. is required and the user has a nice interface that you can bling up with jquery.
I'm not sure how you're seeing the user vs sql vs asp required. From my viewpoint:
asp - setup the page.
ajax - pull options user has access to.
javascript - dynamically create the download links.
jquery - make it look nice.
I get using asp if you're extending a system and you kinda have to use it. I've run into that situation way too many times. But if its a new system, I don't see the point of going asp. Never really liked it and probably never will but that just an opinion and shouldn't be taken for much.
Good luck
Populate the appropriate HTML content from your database, based on user selection via jQuery AJAX
Related
My teachers have always pointed out that client side validation can be easily overcome if the user tries to do so. Therefore functionalities such as validation must be also performed on the server side for a more secure web site.
Since I have started to make a site I need to give the user possibility to clone/duplicate the form for multiple submissions at once. I have done this using jquery.
$(wrapper).append( //wrapper contains id of main div
// some append form code
)
Given that my js code generates this form and appends it below, can the user get any information out of it if he/she so desires and, is there a better way of dynamically generating code if javascript is unsafe or not optimal?
I have a php application with MySQL for database.
I want to create a site builder. The idea is to use ajax for loading and storing the dynamic page content. The user will be able to modify the site (create and edit pages, navigation menus, etc.) while viewing the front-end. The changes will be presented in real time, and then committed once saved.
I'm not sure what would be the best method for manipulating and storing the dynamic page content.
Should I just change the DOM, and then save its current state somehow? Or, would it be better to use an object for storing the page's content and structure? Would it be better to store the pages in SQL, or file?
EDIT
So, what I decided on, if it helps anyone (and thanks to all who responded!):
I have created jQuery functions which allow the user to manipulate the DOM simply by clicking an element on the page, and then adding content to a new element (so for example I have a text and image insert tool). I'm using a handler object to track changes, which are then applied to the DOM once the user clicks update button.
Once the user saves the page, I am using ajax to save a portion of the DOM to a MySQL database.
Then I have a pagebuilder function created which calls my custom theme's header, pulls the html from the database, and then calls the theme's footer.
So far this is working very well. The pagebuilder takes care of constructing the page by using the url's ?page=x reference. This still allows my core app and theme system to control each page's header and footer, while still allowing for an easy way to edit, save and retrieve the content, all using ajax.
Based on my experience with Magento and your dynamic things, i think it'll better to save the dynamic content on database, but saving things like:
"Home"
"3 columns"
"Input - Text"
...
And when you get it back, you use the "directions" saved on database, to build your dynamic website.
I would say that it is a matter of architecture here. Storing in a Database will provide you better performance retrieving and storing long data streams, and will probably a better data organization along the way.
The question is -how can you store a Web site into a Database efficiently?-
Has a partner say before there are many ways of skin the cat. How complex do you want to go? are you going to store single pages? images? tables? full websites? will your users be able to store raw/other data too?
You see?
Hope it helps.
I've been given a task, which I believe my employer is just putting a carrot in front of me and seeing how far I will run.
A vendor has provided us with a form application. This application is in ASP. My task is to see if its possible to Pre-populate this ASP application because we want to host a little 'mini-wizard' questionnaire on our site and when you click submit on the 'mini-wizard' it pre-populates a few fields on the application.
My first question to him was "Do we have access to the ASP code behind to look for parameters passed via Get/Post. - NO
I thought, ok, so there is no way to do it. He then said you may be able to do it with javascript. Which I could see if I could put JS on the application page, but I can't do that either.
My final idea would be to make an ajax call for that page, modify the contents and then display it on our site. I am not sure that would even work, have never tried making an AJAX call to an ASP page from a non-asp site.
Can it be done or is this some form of new developer hazing?
Yes it can be done. As you are going to use client side ajax, the page will give you nothing but the HTML output of that page. So you just need to know that what parameters you need to pass to that page. Even there might be no need to pass parameters.So, Take an asp page of your own and do the ajax call
I have a wordpress site, and i'm not a php developer and not very eager to start either so I'm avoiding it like the plague, but I do have a requirement that requires a little bit of extra coding. I need to:
go to a different website,
download that page,
check for a certain phrase,
if phrase exists, extract a link from that page
and if link is returned I need to show that link on my wordpress site.
Currently, I have an asp.net page that does this and i'm hosting that page in an iframe on my wordpress site. but i'd like to do it without an iframe.
Question is, is there anyway for javascript to go to a different page (my asp.net page) and get a parameter (link) from it. If link is provided i will show certain content on wordpress site.
Or can javascript download a text file from the server? problem with that is i need a trigger to update the text file.
Any advice is appreciated.
Thanks.
What you should understand is that by "avoiding [PHP] like the plague" you're inadvertently avoiding the proper way of doing things. Javascript is a client-side language, and PHP is a server-side language. By asserting that you only want the load on the client's end (the kind of logic involved in what you want to do isn't exactly lightweight), you can potentially end up with a VERY slow webpage.
Not to mention, this type of situation is analogous to using a hammer to do a backhoe's job.
Either way, to answer your question, yes. You can use the jQuery Load method in tandem with Javascript's Match method.
What you should TRY to do, however, is make a CURL request using PHP, and then cache the page on your server. By doing this, you will limit the number of calls to a given page, and optimize load times.
Please consider the second option, even as an attempt in good practice. Good luck.
Use ajax and connect to a different page (on your server) which is written in server-sided language (like asp.net, as you said), that connects to the remote website.
More about Ajax
I've written some pages with ASP.net Repeater and GridView objects. I've seen that some other programmers write pages with these objects; but they make these objects do very nifty things.
For example, I've seen pages where a user clicks on a button and a jQuery dialog appears. When the user enters data into the dialog and clicks a button, the data is submitted using AJAX and the gridview/repeater is updated without reloading the page or posting back.
What are good practices for accomplishing this?
The gridview and the repeater are ASP.NET objects that the .NET framework translates into HTML for you.
What those pages are doing is posting some data to the server. Waiting for new data then using standard DOM manipulation to change the auto generated HTML on the page.
Once the code gets to the client and it's handled asynchronously most of the data is done via DOM manipulation on the client without touching ASP.NET code.
Alternatively they use AJAX controls from ASP.NET like the update panel. I'm not certain how ASP.NET handler ajax calls internally as I'm restricted to the limited AJAX functionalities of .NET 2.0.
So what is are good practices:
Set up your asp.net controls to create nicely formatted HTML and manipulate it by hand using high-level dom manipulation libraries like jQuery., You need to have a good knowledge of your html output rather then your aspx files content.
I´m putting thouse controls into updatepanel[mode conditional].
i´m using jquery to edit some data, or maybe create data. Sending to server via webservice and after successfull saving, i reload the updatepanel. for me the easiest way