加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 没有代码隐藏的ASP.Net

发布时间:2020-12-16 00:14:15 所属栏目:百科 来源:网络整理
导读:我想创建一个没有所有代码隐藏和设计器东西的ASP.Net页面. 基本上我想回到ASP经典,但保留CLR和基类库使.Net非常好. 我想要一个像这样的页面: htmlbodydiv % int customerID = Request.QueryString["CustomerID"]; //Customer and DataAccess classes come f
我想创建一个没有所有代码隐藏和设计器东西的ASP.Net页面.
基本上我想回到ASP经典,但保留CLR和基类库使.Net非常好.
我想要一个像这样的页面:


<html>
<body>
<div>

  <%
    int customerID = Request.QueryString["CustomerID"];
    //Customer and DataAccess classes come from an extenal assembly
    Customer customer = DataAccess.GetCustomer(customerID); 
  %>
  You asked for Customer with ID: <%=customerID;%><br />
  Name: <%=customer.Name;%><br />
  Phone: <%=customer.Phone;%><br />


</div>
</body>
</html>

然而,似乎有一些问题.

> Request对象仅在Page对象中可用.我希望完全删除代码隐藏和设计器页面.
>没有intellisense
>在我深入研究之前,我应该注意什么?
>不知道如何开始拉入外部库

解决方法

如果你不想,你不需要在代码隐藏中做任何事情.

要导入名称空间,请使用import指令:

<%@ Import namespace="System.Web" %>

要导入外部库,请使用Assembly指令:

<%@ Assembly Name="YourAssemblyName" %>

导入System.Web将允许您对HttpContext.Current.Request对象进行智能感知访问.它还将为您提供该命名空间中任何其他对象的智能感知,就像代码文件一样.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读