首页 \ 问答 \ 如何以编程方式创建和添加asp.net页面到Asp.net项目?(How to create and add asp.net page programmatically to Asp.net project?)

如何以编程方式创建和添加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
更新时间:2022-06-20 16:06

最满意答案

这个正则表达式有效吗?

\\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.)

相关问答

更多
  • 我找到了解决此问题的方法: 在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位 ...
  • 尝试使用正向前瞻(有关详细信息,请参阅本文的示例)。 例如,如果我们在正则表达式的末尾添加(?=\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 ...
  • 我假设,方括号或圆括号之间的内容既不包括“自己的”括号也不包括“其他”括号,因此在内容中禁止使用: [ , ] , (和)等字符进行匹配。 为了使正则表达式更有用,我在(和)之间设置了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 ...
  • 这个正则表达式有效吗? \\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.)
  • 而不是$ 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 ...
  • 那么,编辑就会从令牌中去掉大括号,并从这个问题中解脱出来,现在使用.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, ...
  • 这个正则表达式将起作用 .*(\[.*\]) 正则表达式演示 更高效和非贪婪的版本 .*(\[[^\]]*\]) 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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)