当前日期:
Lbll.Text = DateTime.Now.ToLongDataString();
This.controls.Add(lbl);
URL:
HyperLink reg = new HyperLink();
Reg.Text = “Register;
Reg.NavigateUrl = Context.Request.ApplicationPath + “Myfirst.aspx”;
推断用户受权:
Context.User.Identity.IsAuthenticated;
表格相干:
1. 新建一图片img
2. img添加到cell
3. cell添加到row
4. row添加到Table
5. Table添加到PlaceHolder
Table tb = new Table(); TableRow row = new TableRow(); Image img = new Image(); img.ImageUrl = "Images/winbook.gif"; img.ImageAlign = ImageAlign.Middle; img.Width = new Unit(24, UnitType.Pixel); img.Height = new Unit(24, UnitType.Pixel); cell = new TableCell(); cell.Controls.Add(img); row.Cells.Add(cell); HyperLink lnk = new HyperLink(); lnk.Text = "News"; lnk.NavigateUrl = "News.aspx"; row.Cells.Add(cell); tb.Rows.Add(row); phNav.Controls.Add(tb);
将已考证身份的用户重定向回最初要求的URL
public static void RedirectFromLoginPage(string userName,bool createPersistentCookie);
参数
userName
用于 Cookie 身份考证的用户称号。这不须要映照到帐户称号,并将由 URL 身份考证运用。
createPersistentCookie
指定是不是应该发出持久性 Cookie(跨浏览器会话保留的 Cookie)。
规范数据库操纵1
String sql; SqlCommand cmd; SqlConnection conn; Sql = “insert into …”; conn = new SqlConnection (“data source = (local); initial catalog = caoxicao;userid = sa”); cmd = new SqlCommand (sql,conn); conn.open(); cmd.ExecuteNonQuery();
规范数据库操纵2
SqlConnection conn; SqlCommand cmd; SqlDataReader reader; string sql; sql = “select * from TableName”; conn = new SqlConnection (“data source = (local); initial catalog = caoxicao;userid = sa”) cmd = new SqlCommand(sql,conn); conn.open(); reader = cmd.ExecuteReader();
可以用reader的Read()要领推断是不是真的返回了值
If (reader.Read()) ...{ This.Email.Text = reader[“Email”].ToString(); } DataSet 基础操纵 DataSet dsCaoxicao; String sql; SqlConnection conn; SqlDataAdapter adPlaces; conn = new SqlConnection (“data source = (local); initial catalog = caoxicao;userid = sa”) adPlaces = new SqlDataAdapter(sql,conn); dsCaoxiCao = new DataSet(); conn.Open(); adPlaces.Fill(dsCaoxiCao,”Places”);
以上就是C#Web应用程序入门典范笔记(上册)的细致内容,更多请关注ki4网别的相干文章!