如何以编程方式创建和添加asp.net页面到Asp.net项目?(How to create and add asp.net page programmatically to Asp.net project?)
我正在研究一个项目CMS,我正在使用html编辑器动态创建页面。我的成就是我已经成功创建了html页面问题是我坚持到如何使用c#创建asp.net页面并将其分配给掌握2页主要问题。
1-在目录中创建的页面是当前主机或域上当前未打开的页面,表明它不是项目的一部分。
2 - 如何使用主页programaticaly创建asp.net页面,以便在其body标签中我将添加位于当前目录中的创建的html页面。
所以告诉我如何创建asp.net页面并将其作为项目的一部分并在此处分配一个母版页是一个代码如何在当前目录中创建html页面
string content = "<!DOCTYPE html><html><header><title>{MY_TITLE}</title></header><body>{body}</body></html>"; List<string> lines = new List<string>(); content = content.Replace("{MY_TITLE}", titleTextBox.Text); string name = TextBox1.Text; content = content.Replace("{body}", Editor2.Content); lines.Add(content); string nameP = seelctName(Convert.ToInt32(name)); nameP = nameP.Replace(" ", ""); File.WriteAllLines(AppDomain.CurrentDomain.BaseDirectory + "\\" + nameP + ".htm", lines.ToArray());
但我正在考虑将这个内部内容分配给新创建的asp.net页面,使用c#链接到母版页并使其成为项目的一部分,也意味着在域中打开
I am working on a project CMS where i am creating pages dynamically using html editor .My achievement is that i have created html page successfully now problem is that i am stuck to the point how to create asp.net page using c# and assigning it to master page 2 major problems.
1-the page created in directory that is current and not open on local host or domain that shows that it is not a part of project.
2-How to create asp.net page using master page programaticaly so that in its body tag i will add the created html page located in current directory.
so tell me how should i create asp.net page and make it the part of project too and assign it a master page here is a code how i am creating html page in current directory
string content = "<!DOCTYPE html><html><header><title>{MY_TITLE}</title></header><body>{body}</body></html>"; List<string> lines = new List<string>(); content = content.Replace("{MY_TITLE}", titleTextBox.Text); string name = TextBox1.Text; content = content.Replace("{body}", Editor2.Content); lines.Add(content); string nameP = seelctName(Convert.ToInt32(name)); nameP = nameP.Replace(" ", ""); File.WriteAllLines(AppDomain.CurrentDomain.BaseDirectory + "\\" + nameP + ".htm", lines.ToArray());
But i am thinking to assign this inner content to newly created asp.net page using c# linked to master page and make it a part of project mean open in domain too
原文:https://stackoverflow.com/questions/38834062
最满意答案
这个正则表达式有效吗?
\\par\}
只需将其替换为
\}
(注意反斜杠转义,因为
\
和}
都是正则表达式中的特殊字符。)Is there some reason this regex doesn't work?
\\par\}
Just replace it with
\}
(Notice the backslash escapes, because both
\
and}
are special characters in regex.)
相关问答
更多-
Regex Newline Jboss(Regex Newline Jboss)[2022-07-02]
我找到了解决此问题的方法: 在notepad ++中,搜索选项卡中有一项功能 - >在文件中查找...发布所有文件所在的路径。 检查正则表达式并匹配换行符。 输入你的正则表达式,然后单击查找全部。 I found a workaround to this problem: In notepad++ there is a feature in Search tab --> Find in Files... Post the path where all the files are located. Check ... -
没有区别。 对不起,我把它拿走了。 Regx101的作者Firas Dib选择解释各种令牌的唯一区别。 literal字符或匹配literally是指在文本中指定实际字符:例如, a匹配a ,而不是字符类,例如\w ,也可以匹配a 。 您可以通过以下三种方式之一匹配文字句点: \. [.] [\.] 哪个选项更好? 有些人喜欢选项2,因为它清楚地表明你匹配的是一个时期,而不是全能点。 它脱颖而出。 对我自己来说,我用\. 。 有些人会说使用字符类不太理想,但在现代处理器上它并没有什么区别。 你选。 选项3位 ...
-
仅当输入结束或使用Newline / Whitespace时,.Net正则表达式匹配(.Net Regex match only if input ends or with Newline/Whitespace)[2023-07-10]
尝试使用正向前瞻(有关详细信息,请参阅本文的示例)。 例如,如果我们在正则表达式的末尾添加(?=\s|$) ,它将仅匹配字符串后跟空格或字符串结尾,但不匹配此空格: ^Identifier ([a-zA-Z0-9-_]+)(?:\(([^)(]*)\))?(?=\s|$) Try to use the positive lookahead (for more details see for example this article). For example, if we add (?=\s|$) at ... -
正则表达式匹配括号内容(Regex to match content of bracket)[2022-03-26]
我假设,方括号或圆括号之间的内容既不包括“自己的”括号也不包括“其他”括号,因此在内容中禁止使用: [ , ] , (和)等字符进行匹配。 为了使正则表达式更有用,我在(和)之间设置了2个捕获组,#和[和]之间的#1,以帮助确定捕获的内容周围的括号。 要匹配方括号(带有捕获组)之间的内容,您需要: \[([^\[\]()]+)\] 并匹配圆括号(括号,也包括捕获组)之间的内容,您需要: \(([^\[\]()]+)\) 以上“部分”正则表达式(对于每个变体)都是最终正则表达式中的替代,因此它们用|分隔 ... -
op4没有usr元素。 在插入小图后,usr被更改。 要重置,可以使用类似这样的东西: dev.off() plot(1:10) usr <- par("usr") op4 <- par(fig=c(0.1,0.8,0.3,0.8), new=TRUE) plot(rnorm(400), type="l") par(op4) par(usr=usr) mtext("hello", adj=1, col=4); mtext("hello", adj=0, col=4) op4 does not have a ...
-
RegEx匹配一些文字“\ par”NewLine和一个括号(RegEx to Match Some Literal “\par” NewLine and a bracket)[2023-11-24]
这个正则表达式有效吗? \\par\} 只需将其替换为\} (注意反斜杠转义,因为\和}都是正则表达式中的特殊字符。) Is there some reason this regex doesn't work? \\par\} Just replace it with \} (Notice the backslash escapes, because both \ and } are special characters in regex.) -
我如何使用正则表达式匹配“最终”而不允许换行符?(How can I use regex to match “the end” without allowing a newline there?)[2024-02-16]
而不是$ use \Z ,它只匹配字符串的末尾。 >>> re.match(r'^abc\Z', 'abc') <_sre.SRE_Match object at 0x02469560> >>> re.match(r'^abc\Z', 'abc\n') >>> 注意:这个答案具体取决于Python中\Z的含义。 这个概念通常在其他正则表达式实现中拼写为 \z 。 你也可以使用负向前视断言,但是它的语法在正则表达式实现中也会有所不同。 有关在Python中使用负向前视断言的示例,请参阅dawg的答案 。 I ... -
找到与Regex匹配的括号(Find matching bracket with Regex)[2021-07-28]
那么,编辑就会从令牌中去掉大括号,并从这个问题中解脱出来,现在使用.Net Regexes,使用平衡组很容易实现。 它简单地匹配大括号,这是一个基本的例子。 就像KennyTM的答案一样,只有当你移除顶级大括号时,它才会起作用,否则它将匹配整个输入。 再次,这更好地用于娱乐目的: (?: # try matching... (?:\\[{}]|[^\s{}])+\s*? # a literal (allow escaped curly braces) | ... -
我不确定您要解析的数据格式及其来源,但它看起来像JSON。 对于此特定字符串,从字符串的开头和结尾添加方括号使其可加载JSON : In [1]: data = '[1,null,"7. Mai 2017"],[2,"test","8. Mai 2018"],[3,"test","9. Mai 2019"]' In [2]: import json In [3]: json.loads("[" + data + "]") Out[3]: [[1, None, u'7. Mai 2017'], [2, ...
-
匹配最后一个括号(Match the last bracket)[2024-01-29]
这个正则表达式将起作用 .*(\[.*\]) 正则表达式演示 更高效和非贪婪的版本 .*(\[[^\]]*\]) C#代码 string input = "atext[d][][ef]\nother[aa][][a]\nxxxxx[][xx][x][][xx]\nyyyyy[]"; string pattern = "(?m).*(\\[.*\\])"; Regex rgx = new Regex(pattern); Match match = rgx.Match(input); while (ma ...