ASP.NET 连接数据库
这个东西太纠结了~贴出来代码,供大家享用
分三个部分:.config .aspx .aspx.cs
//web.config
<appSettings>
<add key="keystring" value="Data Source=ZRQ-PC;Initial Catalog=OnlineJudge;Integrated Security=True"/>
</appSettings>
//page.aspx
<form id="form2" name="form2" method="post" action="">
<asp:Panel ID="unlogin" runat="server">
<div class="Login" align="center">
<p>Login</p>
用户名<asp:TextBox ID="username" runat="server" Width="106px"></asp:TextBox><br />
密码 <asp:TextBox ID="password" runat="server" Height="22px" Width="106px"></asp:TextBox><br />
<asp:Button ID="submit" runat="server" Text="登录" onclick="submit_Click" />
<asp:Button ID="register" runat="server" Text="注册" />
</div>
</asp:Panel>
<asp:Panel ID="allogin" runat="server" Visible="false">
<div class="Login" align="center">
<asp:Label ID="welcome" runat="server" Text="Label"></asp:Label><br />
<asp:Button ID="alterinfo" runat="server" Text="修改信息" /><br />
<asp:Button ID="logout" runat="server" Text="注销登陆" /><br />
<asp:Button ID="register1" runat="server" Text="注册新用户" /><br />
<asp:Button ID="relogin" runat="server" Text="重新输入密码" />
</div>
</asp:Panel>
</form>
//page.a
相关文档:
在ASP.NET Web窗体应用程序中,推荐的方法是将容器存到由Application字典对象提供的全局状态。当需要的时候你可以访问容器,甚至使用HTTP模块自动完成对页面上控件的注入。
通常情况下,你应该使用Application字典对象来存储容器的单个实例。您可能决定创建主要容器的子容器,并将它们存储到每个用户的Session对象中,甚至 ......
The MVC bits have finally arrived and I’ve spent a while digesting them. I’ve been waiting for the bits to be released to begin working on a side-project, so the first thing I did after downloading them last night was crank it up and start working on a new ASP.NET MVC Web Application p ......
在本篇文章中,我们将讨论编程人员在使用ASP.NET开发应用程序时需要注意的10个技巧,这些技巧涉及从缺省的控件、表单名的改变到StringBuilder类的使用,有助于编程人员能够尽快地适应.NET环境。
1、在使用Visual Studio .NET时,除直接或非引用的对象外,不要使用缺省的名字
.NET带来的好处之一是所有的源代码和 ......
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open
('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="++"')</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.为按钮添加对话框
Button1.Attributes.Add("o ......
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ......