?? editsubscription.aspx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using ASPNET.StarterKit.Communities.Services;
namespace ASPNET.StarterKit.Communities.Admin.EditServiceSubscriptions
{
/// <summary>
/// Summary description for EditSubscription.
/// </summary>
public class EditSubscription : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblError;
protected System.Web.UI.WebControls.TextBox txtServiceName;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtServiceUrl;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.TextBox txtPassword;
protected System.Web.UI.WebControls.Button btnEdit;
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
//*******************************************************
//
// Store the ID of the service being edited
// in View State.
//
//*******************************************************
int ServiceID {
get {return (int)ViewState["ServiceID"]; }
set {ViewState["ServiceID"] = value; }
}
//*******************************************************
//
// Retrieve the service information when the page first
// loads and assign the information to the form
// fields.
//
//*******************************************************
void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
// Get service name from query string
string serviceName = Request.QueryString["id"];
// Retrieve service info
ServiceSubscriptionInfo serviceInfo = ServiceUtility.GetServiceSubscriptionInfo(serviceName);
// Store service id in view state
ServiceID = serviceInfo.ID;
txtServiceName.Text = serviceInfo.Name;
txtServiceUrl.Text = serviceInfo.Url;
txtPassword.Text = serviceInfo.Password;
}
}
//*******************************************************
//
// Update the service information in the
// database.
//
//*******************************************************
void btnEdit_Click(Object s, EventArgs e) {
if (Page.IsValid) {
ServiceSubscriptionInfo serviceInfo = new ServiceSubscriptionInfo();
serviceInfo.ID = ServiceID;
serviceInfo.Name = txtServiceName.Text;
serviceInfo.Url = txtServiceUrl.Text;
serviceInfo.Password = txtPassword.Text;
int result = AdminUtility.EditServiceSubscription(serviceInfo);
if (result == 0) {
Response.Redirect("Default.aspx");
}
lblError.Visible = true;
}
}
private void Page_Load()
{
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -