Recently saw Beginning C # Web applications Wtith Visual Studio. Net. I feel this book is good in some detail, special notes, for the latter to provide some of the things that may be useful. Let's write some of them today and finish them correctly years ago.
Current Date:
Lbll.text = DateTime.Now.ToLongDataString ();
THIS.CONTROLS.ADD (LBL);
Url:
HyperLink reg = new HyperLink ();
Reg.text = "Register;
Reg.navigateurl = Context.Request.ApplicationPath + "myfirst.aspx";
To determine user authorization:
Context.User.Identity.IsAuthenticated;
Table Related:
1. Create a new image img
2. IMG Added to cell
3. Cell added to row
4. Row added to table
5. Table added to 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 (unittype.pixel); Img. Height = new Unit (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);
Redirect Authenticated users back to the originally requested URL
public static void RedirectFromLoginPage (String Username,bool createpersistentcookie);
Parameters
UserName
The user name used for Cookie authentication. This does not need to be mapped to the account name and will be used by URL authentication.
createPersistentCookie
Specifies whether persistent cookies should be issued (cookies saved across browser sessions).
Standard database Operations 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 ();
Standard Database Operations 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 ();
You can use the Read () method of reader to determine if a value is actually returned
if (reader. Read ()) ... {This.Email.Text = reader["Email"]. ToString (); } DataSet basic Operation 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");