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 ......
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 ......
只有在◎Page指令中设置了:AutoEventWireup="true",服务器端的编译器将按照 Page_eventname 方法名的形式自动的检查相应事件处理方法,自动实现事件的订阅。
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System ......
在.Net 4.0之前我们为了做出搜索引擎友好的,对用户也友好的url都是需要自己实现Url重写,现在不需要了,.Net 4.0为我们做这一切。UrlRouting之所以称之为Routing是因为它不但实现了Url重写还可以通过参数得到重写后的Url在页面上使用。
1. Url Routing 的通常用法
UrlRouting在Asp.Net Mvc项目中被广泛使用,在Mvc中很好 ......