如何在aspx页面中编写代码 [英] how to write code in aspx page

查看:203
本文介绍了如何在aspx页面中编写代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在aspx页面中编写代码,该代码连接到数据库并在页面中显示数据.我不想使用代码隐藏页或.cs文件

i want to write code in aspx page which connect to database and display data in page. i dont want to use code-behind page or .cs file

推荐答案


将新页面添加到项目的右上角时,您将得到一个名为将代码放置在单独的文件中"的复选框,只需取消选中该复选框即可.

http://www.c-sharpcorner.com/uploadfile/NikhilJohari /single-file-mode-in-Asp-Net/ [
Hi,
While adding a new page to the project in right corner you will get a check box named "Place code in separate file" just uncheck that.

http://www.c-sharpcorner.com/uploadfile/NikhilJohari/single-file-mode-in-Asp-Net/[^]

--AK


你好Manohar
请找到这个

Hello Manohar
Please Find this

<%@ Page Language="C#" %>
<script runat="server">
void Button1_Click(Object sender, EventArgs e)
{
    Label1.Text = "Clicked at " + DateTime.Now.ToString();
}
</script>
<html>
<head>
  <title>Single-File Page Model</title>
</head>
<body>
  <form runat="server">
    <div>
       <asp:Label id="Label1"

         runat="server" Text="Label">
       </asp:Label>
       <br />
       <asp:Button id="Button1"

         runat="server"

         onclick="Button1_Click"

         Text="Button">
      </asp:Button>
    </div>
  </form>
</body>
</html>


当我们在解决方案中添加新页面时,将出现一个复选框,即将代码放置在单独的文件中"取消选中该复选框.那么您可以在aspx页面中进行编码.
when we add a new page in solution then there is a checkbox which is "Place code in Seprate file" uncheck it. then you can code in aspx page.


这篇关于如何在aspx页面中编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆