在線人數 application.Lock(); Application["num"] =(Convert.ToInt32(Application["num"]) + 1).ToString(); Application.UnLock(); Label1.Text = Application["num"].ToString();session Application傳值Session["user"] = TextBox1.Text; Response.Redirect("Default2.aspx");Server進行編碼和解碼 Response.Write(Server.UrlEncode("http://www.abc.com"));虛擬路徑轉為絕對路徑Server.MapPath()使用cookie來獲取用戶名或者密碼 Response.Cookies["user"].Value = "zhangsan"; Response.Cookies["pass"].Value = "1234"; String str=Response.Cookies["pass"].Value; Label2.Text = "寫入成功!";讀取數據Label2.Text = Server.HtmlEncode(Request.Cookies["user"].Value); Label1.Text = Server.HtmlEncode(Request.Cookies["pass"].Value);超鏈接傳值過程 使用占位符:string.Format Response.Redirect(string.Format("Default2.aspx?username={0},pass={1}", TextBox2.Text, TextBox3.Text));接受使用Request.QueryString["user"].ToString();dropdownlist控件 switch (DropDownList1.SelectedItem.Text.Trim()) { case "福建": { ListBox1.Items.Clear(); ListBox1.Items.Add("福州"); ListBox1.Items.Add("廈門"); ListBox1.Items.Add("泉州"); break; } case "廣東": { ListBox1.Items.Clear(); ListBox1.Items.Add("廣州"); ListBox1.Items.Add("汕頭"); ListBox1.Items.Add("中山"); break; } }ListItem foreach (ListItem l in ListBox1.Items) { if (l.Selected == true) { Label1.Text = l.Text; } }集合單選的控件 for (int i = 0; i < CheckBoxList1.Items.Count; i++) { if (CheckBoxList1.Items[i].Selected) { Label1.Text += CheckBoxList1.Items[i].Text + " "; } }MApkongjian控件 需要三個條件 半徑 X,Y 就可以實現點擊中國地圖跳轉頁面 <asp:ImageMap ID="ImageMap1" runat="server" ImageUrl="~/img/p3.jpg"> <asp:CircleHotSpot Radius="15" X="10" Y="10" /> <asp:CircleHotSpot Radius="100" X="200" Y="500" /> <asp:CircleHotSpot Radius="40" X="40" Y="90" /> <asp:CircleHotSpot Radius="300" X="400" Y="600" /> </asp:ImageMap>server對象的Transfer方法和respone的Redirect()兩者的區別就 跟jsp的 重定向和URL不改變相似第一個不該變地址在Transfer跳轉頁面后也可以傳值在頁面出傳值有多種方法 Request.QueryStrnng() Session Application PReviousPage.FindControl TextBox tb1 = (TextBox)PreviousPage.FindControl("TextBox2"); TextBox tb2 = (TextBox)PreviousPage.FindControl("TextBox3"); Label1.Text = tb1.Text; Label2.Text = tb2.Text;master母版頁使用存儲過程使用ALTER PROCEDURE dbo.update_user /* ( @parameter1 int = 5, @parameter2 datatype OUTPUT ) */ @sid int, @sname varchar(20), @spassWord varchar(12), @sex char(10), @saddress varbinary(50), @img varbinary(50)AS /* SET NOCOUNT ON */ update tb_user set sname=@sname,spassword=@spassword,sex=@sex,saddress=@saddress,img=@img RETURN后臺更新數據庫值要說明是存儲過程
|
新聞熱點
疑難解答