简体   繁体   English

HTML 代码段生成器 - Javascript

[英]HTML Snippet Generator - Javascript

I'm trying to write a system that will produce HTML snippets for users dependant on what they choose from a number of options.我正在尝试编写一个系统,该系统将为用户生成 HTML 片段,具体取决于他们从多个选项中选择的内容。

Each user will have a unique ID (already in SQL DB) which links to the options they are allowed to select from.每个用户将有一个唯一的 ID(已经在 SQL DB 中)链接到他们被允许从 select 的选项。

Does anyone have any ideas how I should go about doing this?有谁知道我应该如何 go 这样做? The pages are ASP.NET C# but I'd prefer to use HTML, JQuery & Javascript for the UI. 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.但是我确实需要从 SQL 中提取相关信息。

Thanks for any replies!感谢您的回复!

No problem using html & jquery for the ui.将 html 和 jquery 用于 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.您可以在 asp 中创建一个基本的站点布局,并利用母版页来限制使用任何跨页内容重复您的工作。

You can add form controls to the pages in asp but don't use server side controls.您可以在 asp 中向页面添加表单控件,但不要使用服务器端控件。

Use the regular html form controls so you don't get any post back on user input.使用常规的 html 表单控件,这样您就不会收到用户输入的任何回复。

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.标签中的“runat=server”将导致服务器回发。 Not something you will want if you're planning on using javascript for the ui.如果您打算将 javascript 用于 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.设置页面后,您可以将 javascript/jquery 附加到那些 html 表单控件并使用 ajax 查询数据库以限制用户选择。

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.因此,如果用户登录系统并看到他们可以下载的许多徽标和文本变体,我将使用 ajax 来查询用户可以访问哪些组合并使用该信息,使用 javascript 动态创建下载按钮/链接。

That way no redirect/page refresh etc. is required and the user has a nice interface that you can bling up with jquery.这样就不需要重定向/页面刷新等,并且用户有一个很好的界面,您可以使用 jquery 来炫耀。

I'm not sure how you're seeing the user vs sql vs asp required.我不确定您如何看待用户 vs sql vs asp required。 From my viewpoint:从我的角度来看:

  1. asp - setup the page. asp - 设置页面。
  2. ajax - pull options user has access to. ajax - 用户有权访问的拉取选项。
  3. javascript - dynamically create the download links. javascript - 动态创建下载链接。
  4. jquery - make it look nice. jquery - 让它看起来不错。

I get using asp if you're extending a system and you kinda have to use it.如果您要扩展系统并且您必须使用它,我会使用 asp。 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.但如果它是一个新系统,我看不出使用 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根据用户通过jQuery AJAX进行的选择,从数据库中填充适当的 HTML 内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM