如何保存 style-css 值供以后使用,然后重新加载这些值 [英] How to save style-css values for Later use then Reload those values back

查看:25
本文介绍了如何保存 style-css 值供以后使用,然后重新加载这些值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拥有所有 SQL 数据库表及其列名的列表,每个都在 List

Having a list of all SQL database-tables and their columns-names, each in List<string>

通过下拉列表控件,我已经选择了一个表和它的列,然后在第一阶段之后,我选择了表格和列我正在导航到一个具有 Graphical User interface 的页面,如下图所示:

Via a dropDown list control I already chose a table and the columns it has, then after the first stage, where I have chosen the table and it's columns I am navigating to a page that's has a Graphical User interface like in this screenshot:

然后就像你在图片中看到的那样,渲染一个 html 表格,选择的列作为 htmlTable 的标题.

It will then as you could see in the picture, render an html table , with chosen columns as the htmlTable headers .

所以现在当结果显示在那个 aspx 页面中时,

So now when result is displayed in that aspx page,

通过使用 Jquery,我设法实现了一个测试工具.

By using Jquery, I have managed to implement a test-tool.

这使我能够通过 Graphical User interface 应用一些样式设置 - 在该表上,现在它只是 headers fonts-namesheaders background-颜色列宽:

This enables me to apply some style setting via Graphical User interface - on that table, and for now its just headers fonts-names , headers background-color and the columns width :

标题字体 .

字体由 AJAX ToolKit autoComplete Extender 选择,目标是专用的 asp:TextBox,字体名称作为其 dataSource

fonts are being chosen by an AJAX ToolKit autoComplete Extender targeting a dedicated asp:TextBox with fonts names as its dataSource

因此 textchange 事件 - jQuery 正在绑定选定的值...相应地进行预览.

So on textchange event - jQuery is binding selected value...accordingly for a preview .

相同的背景

通过使用 jQuery 颜色选择器,它的 事件处理程序 正在执行将所选颜色应用为 <tr> bgcolor ...etc 的工作

By using a jQuery color picker, which with it's event handler is doing the job of applying the selected color as the <tr> bgcolor ...etc '

既然我已经选择了所有的 css 值,我需要将它们用于网站应用程序

Now that I have all chosen css values i need to use those for a webSite application

实现这一目标最简单的方法是什么?

What is the simplest way to achieve this goal ?

我可以考虑通过 File.WriteAllText 生成它,

I could think of generating it through a File.WriteAllText ,

这样的结果将是一个用文本生成的文本创建的新文件是 .aspx 网络表单页面的头部部分(通过 String.Format 自动生成)

So that way result will be a new File created with text generated text is a head section of .aspx webform page (auto generated via String.Format)

string formatedStyleStr = string.Format(" <style Type="text/css"> #{0} { 
	width: {1};", ID values of jQuery's job);

就是这个想法...

因为新文件名将是 default 扩展名为 .aspx...

As the new file name will be default with an extension .aspx...

然后以编程方式写入格式化字符串,就像手动写入一样

Then write into it programmatically formatted string as you would manually write it

通常在启动一个新的空网站应用时.

When usually starting a new empty website application.

因此,您将添加现有项目"...

或者我可以做的其他选择来实现这个结果.我还没有决定如何......

or other options I could do to achieve this result. i did not yet decide how to ...

只是我需要它来保存选择的这些值,

only that i need it to hold these values that was selected ,

因此,当您将通过 Visual Studio 打开此文件进行处理时,您将拥有一种模板(初始样式由图片中的 UI 创建)

so as you will open this file to work on it via visual studio, you will have a kind of a template to start with (the initial style is created by the UI in the picture)

我应该使用哪种方法?

因为我在那个领域没有足够的经验......我想问有没有人已经想到它......并想出了一些实现它的方法.

as i don't have enough experience in that field ....I wanted to ask did anyone think of it already ...and figured some ways to implement it.

推荐答案

试试这个

ASPX

<style type="text/css" runat="server" id="AutogeneratedStyle"></style>

这将创建一个字段 - 在当前 page 中输入 HtmlGenericControl.

This will create a field - type HtmlGenericControl within the current page.

背后的C#代码

然后像这样分配文字 CSS 定义:

then just assign the literal CSS definition like this:

var generatedStyle= string.Format(

                   "-->#idOfElement here<---
                      {
                          background-color:{0};
                      }", someVariables);

AutogeneratedStyle.InnerHtml = generatedStyle;

希望能帮助你入门

这篇关于如何保存 style-css 值供以后使用,然后重新加载这些值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆