相当于PHP的包括C# [英] Equivalent to PHP's include in C#
本文介绍了相当于PHP的包括C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是等效的命令PHP的包括()在C#中?
What is the equivalent command to PHP's include() in C# ?
例如,PHP的包括被用作这样:包括:(ex.php);
For example, PHP's include is used as so : include("ex.php");
灿我做同样的在C#?
推荐答案
如果您使用C#,您可以创建一个用户控件在ASP.Net平均(的.ascx ),并在.aspx页面中添加它。结果
。如果你正在做的MVC你可以创建一个局部视图。
If you mean in ASP.Net using C# you can create a user control (.ascx) and add it in your .aspx page.
If you are doing MVC you can create a partial view.
我能想到的最接近的事将是创建一个名为的MyUserControl一ASCX用户控件后
The closest thing I can think of would be after creating an ascx user control named "MyUserControl"
在你的Page_Load或pre_render:
in your page_load or pre_render :
MyUserControl cont = new MyUserControl();
this.Controls.Add(cont);
这篇关于相当于PHP的包括C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文