.aspx页面中的C#代码 [英] C# code in .aspx page
本文介绍了.aspx页面中的C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个html文件,我在.aspx页面中使用但我必须在.aspx页面中编码而不是在后面。 bcz有html控件,我不能在.cs页面中使用。然后请告诉我如何在.aspx页面中编码,甚至我必须运行插入查询
问候
Neetesh
解决方案
您将在aspx页面中编写服务器端代码。
这可以通过两种方式完成 -
1)直接嵌入代码 - http://weblogs.asp.net/ahmedmoosa/archive/2010/10/06/embedded-code-and-inline-server-tags .aspx [ ^ ]
2)使用较新的Razor引擎 - http://en.wikipedia.org/wiki/ASP.NET_Razor_view_engine [ ^ ]
如何访问html对象后面的代码?
1.将runat =server放到html对象
2. put id =sample
3.然后,您可以在后面的代码中访问sampleid
Hi All,
I have a html file which I use in .aspx page but I have to code in .aspx page not in behind. bcz there are html control which I can not use in .cs page. then please tell me how to code in .aspx page and even I have to run Insert query
Regards
Neetesh解决方案You will be writing server side code within the aspx page.
This can be done in two ways -
1) By embedding code directly - http://weblogs.asp.net/ahmedmoosa/archive/2010/10/06/embedded-code-and-inline-server-tags.aspx[^]
2) By using the newer Razor engine - http://en.wikipedia.org/wiki/ASP.NET_Razor_view_engine[^]
how to access html objects to code behind?
1. put runat="server" to the html object
2. put id="sample"
3. then, you can access the "sample" id in your code behind
这篇关于.aspx页面中的C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文