CommunityServer的登录页面
CommunityServer的登录页面
http://localhost/ccs1.03/login.aspx?ReturnUrl=/Default.aspx
CommunityServerWeb.Themes.default.Skins.Skin-Login.ascx
1<%@ Control Language="C#" %>
2<%@ Import Namespace="CommunityServer.Controls" %>
3<%@ Import Namespace="CommunityServer.Components" %>
4<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
5
6
7<table width="100%" cellspacing="12" cellpadding="0" border="0">
8
9 <tr>
10 <td>
11 <br />
12
13 <table align="center"class="tableBorder" cellspacing="2" cellpadding="5" >
14 <tr>
15 <td class="column" align="left" colspan="2">
16 <CS:ResourceLabel runat="server" ResourceName="Login_Title" />
17 </td>
18 </tr>
19 <tr>
20 <td class="f" align="center" valign="top" colspan="2">
21 <table cellspacing="1" border="0" cellpadding="5">
22 <tr>
23 <td align="right" class="txt3">
24 <CS:ResourceLabel runat="server" ResourceName="Login_UserName" />
25 </td>
26 <td>
27 <CS:DefaultButtonTextBox Button = "loginButton" id="username" runat="server" size="30" maxlength="64" />
28 </td>
29 </tr>
30 <tr>
31 <td align="right" class="txt3">
32 <CS:ResourceLabel runat="server" ResourceName="Login_Password" />
33 </td>
34 <td>
35 <CS:DefaultButtonTextBox Button = "loginButton" TextMode="Password" id="password" runat="server" size="11" maxlength="64" />
36 <span class="txt4">
37 <CS:ForumAnchor AnchorType="UserForgotPassword" runat="server"/>
38 |
39 <CS:ForumAnchor AnchorType="UserRegister" runat="server"/>
40 </span>
41 </td>
42 </tr>
43 <tr>
44 <td></td>
45 <td align="left" class="txt3" nowrap>
46 <asp:CheckBox type="checkbox" runat="server" id="autoLogin" />
47 </td>
48 </tr>
49 <tr>
50 <td></td>
51 <td align="left" class="txt3" nowrap>
52 <asp:LinkButton id="loginButton" runat="server" CssClass = "Button" />
53 </td>
54 </tr>
55 </table>
56 </td>
57 </tr>
58 </table>
59 </td>
60 </tr>
61</table>
62<br>
63<br>
64
2<%@ Import Namespace="CommunityServer.Controls" %>
3<%@ Import Namespace="CommunityServer.Components" %>
4<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
5
6
7<table width="100%" cellspacing="12" cellpadding="0" border="0">
8
9 <tr>
10 <td>
11 <br />
12
13 <table align="center"class="tableBorder" cellspacing="2" cellpadding="5" >
14 <tr>
15 <td class="column" align="left" colspan="2">
16 <CS:ResourceLabel runat="server" ResourceName="Login_Title" />
17 </td>
18 </tr>
19 <tr>
20 <td class="f" align="center" valign="top" colspan="2">
21 <table cellspacing="1" border="0" cellpadding="5">
22 <tr>
23 <td align="right" class="txt3">
24 <CS:ResourceLabel runat="server" ResourceName="Login_UserName" />
25 </td>
26 <td>
27 <CS:DefaultButtonTextBox Button = "loginButton" id="username" runat="server" size="30" maxlength="64" />
28 </td>
29 </tr>
30 <tr>
31 <td align="right" class="txt3">
32 <CS:ResourceLabel runat="server" ResourceName="Login_Password" />
33 </td>
34 <td>
35 <CS:DefaultButtonTextBox Button = "loginButton" TextMode="Password" id="password" runat="server" size="11" maxlength="64" />
36 <span class="txt4">
37 <CS:ForumAnchor AnchorType="UserForgotPassword" runat="server"/>
38 |
39 <CS:ForumAnchor AnchorType="UserRegister" runat="server"/>
40 </span>
41 </td>
42 </tr>
43 <tr>
44 <td></td>
45 <td align="left" class="txt3" nowrap>
46 <asp:CheckBox type="checkbox" runat="server" id="autoLogin" />
47 </td>
48 </tr>
49 <tr>
50 <td></td>
51 <td align="left" class="txt3" nowrap>
52 <asp:LinkButton id="loginButton" runat="server" CssClass = "Button" />
53 </td>
54 </tr>
55 </table>
56 </td>
57 </tr>
58 </table>
59 </td>
60 </tr>
61</table>
62<br>
63<br>
64
CommunityServerControls.Utility.DefaultButtonTextBox.cs
DefaultButtonTextBox 类,重写TextBox。
1//------------------------------------------------------------------------------
2// <copyright company="Telligent Systems">
3// Copyright (c) Telligent Systems Corporation. All rights reserved.
4// </copyright>
5//------------------------------------------------------------------------------
6
7using System;
8using System.Text;
9using System.Web.UI.WebControls;
10
11namespace CommunityServer.Controls
12{
13 /// <summary>
14 /// Provides a simple way to specify a specific button to fire when "Enter" is clicked with in
15 /// the textbox
16 /// </summary>
17 public class DefaultButtonTextBox : TextBox
18 {
19 public DefaultButtonTextBox()
20 {
21
22 }
23
24 #region DefaultButton
25 private WebControl _defaultButton = null;
26
27 /// <summary>
28 /// Attempts to find a reference to the Control specified in the Button property
29 /// </summary>
30 protected WebControl DefaultButton
31 {
32 get
33 {
34 if(_defaultButton == null)
35 {
36 if(Button != null)
37 {
38 _defaultButton = FindControl(Button) as WebControl;
39 if(_defaultButton != null)
40 {
41 if(!(_defaultButton is Button || _defaultButton is LinkButton || _defaultButton is ImageButton))
42 throw new ArgumentException("DefautlButton Property value must be of Type Button, LinkButton, or ImageButton");
43 }
44 }
45 }
46 return _defaultButton;
47 }
48 }
49
50 string _button;
51 /// <summary>
52 /// The ID of the button to wire up to this instance of TextBox
53 /// </summary>
54 public string Button
55 {
56 get{ return _button;}
57 set {_button = value;}
58 }
59 #endregion
60
61 #region PreRender
62 /// <summary>
63 /// Override OnPreRender and test to see if a Button is wired up to the TextBox. If so, render the javascript
64 /// and set the textbox's attributes
65 /// </summary>
66 protected override void OnPreRender(EventArgs e)
67 {
68 if(DefaultButton != null)
69 {
70 ButtonScript();
71 this.Attributes.Add("onkeydown", string.Format(OnKeyDownButtonAttribute,DefaultButton.UniqueID));
72 }
73 base.OnPreRender (e);
74 }
75 #endregion
76
77 #region JavaScript
78
79 /// <summary>
80 /// OnKeyDown Attribute. We use Button, Event since just button did not work in FireFox :)
81 /// </summary>
82 const string OnKeyDownButtonAttribute = "KeyDownHandler('{0}',event);";
83
84 /// <summary>
85 /// Renders the javascript function to fire our postback
86 /// </summary>
87 protected void ButtonScript()
88 {
89 StringBuilder sb = new StringBuilder();
90 sb.Append("<script language=\"javascript\">\n");
91 sb.Append("<!--\n");
92 sb.Append("function KeyDownHandler(btn,event)\n");
93 sb.Append("{\n");
94 sb.Append(" if (event.keyCode == 13)\n");
95 sb.Append(" {\n");
96 sb.Append(" event.returnValue = false;\n");
97 sb.Append(" event.cancel = true;\n");
98 sb.Append(" __doPostBack(btn)\n");
99 sb.Append(" }\n");
100 sb.Append("}\n");
101 sb.Append("\n");
102 sb.Append("//-->\n");
103 sb.Append("</script>\n");
104 Page.RegisterStartupScript("DefaultButtonScript", sb.ToString());
105 Page.RegisterRequiresPostBack(this);
106 Page.GetPostBackEventReference(this);
107 }
108 #endregion
109 }
110}
111
2// <copyright company="Telligent Systems">
3// Copyright (c) Telligent Systems Corporation. All rights reserved.
4// </copyright>
5//------------------------------------------------------------------------------
6
7using System;
8using System.Text;
9using System.Web.UI.WebControls;
10
11namespace CommunityServer.Controls
12{
13 /// <summary>
14 /// Provides a simple way to specify a specific button to fire when "Enter" is clicked with in
15 /// the textbox
16 /// </summary>
17 public class DefaultButtonTextBox : TextBox
18 {
19 public DefaultButtonTextBox()
20 {
21
22 }
23
24 #region DefaultButton
25 private WebControl _defaultButton = null;
26
27 /// <summary>
28 /// Attempts to find a reference to the Control specified in the Button property
29 /// </summary>
30 protected WebControl DefaultButton
31 {
32 get
33 {
34 if(_defaultButton == null)
35 {
36 if(Button != null)
37 {
38 _defaultButton = FindControl(Button) as WebControl;
39 if(_defaultButton != null)
40 {
41 if(!(_defaultButton is Button || _defaultButton is LinkButton || _defaultButton is ImageButton))
42 throw new ArgumentException("DefautlButton Property value must be of Type Button, LinkButton, or ImageButton");
43 }
44 }
45 }
46 return _defaultButton;
47 }
48 }
49
50 string _button;
51 /// <summary>
52 /// The ID of the button to wire up to this instance of TextBox
53 /// </summary>
54 public string Button
55 {
56 get{ return _button;}
57 set {_button = value;}
58 }
59 #endregion
60
61 #region PreRender
62 /// <summary>
63 /// Override OnPreRender and test to see if a Button is wired up to the TextBox. If so, render the javascript
64 /// and set the textbox's attributes
65 /// </summary>
66 protected override void OnPreRender(EventArgs e)
67 {
68 if(DefaultButton != null)
69 {
70 ButtonScript();
71 this.Attributes.Add("onkeydown", string.Format(OnKeyDownButtonAttribute,DefaultButton.UniqueID));
72 }
73 base.OnPreRender (e);
74 }
75 #endregion
76
77 #region JavaScript
78
79 /// <summary>
80 /// OnKeyDown Attribute. We use Button, Event since just button did not work in FireFox :)
81 /// </summary>
82 const string OnKeyDownButtonAttribute = "KeyDownHandler('{0}',event);";
83
84 /// <summary>
85 /// Renders the javascript function to fire our postback
86 /// </summary>
87 protected void ButtonScript()
88 {
89 StringBuilder sb = new StringBuilder();
90 sb.Append("<script language=\"javascript\">\n");
91 sb.Append("<!--\n");
92 sb.Append("function KeyDownHandler(btn,event)\n");
93 sb.Append("{\n");
94 sb.Append(" if (event.keyCode == 13)\n");
95 sb.Append(" {\n");
96 sb.Append(" event.returnValue = false;\n");
97 sb.Append(" event.cancel = true;\n");
98 sb.Append(" __doPostBack(btn)\n");
99 sb.Append(" }\n");
100 sb.Append("}\n");
101 sb.Append("\n");
102 sb.Append("//-->\n");
103 sb.Append("</script>\n");
104 Page.RegisterStartupScript("DefaultButtonScript", sb.ToString());
105 Page.RegisterRequiresPostBack(this);
106 Page.GetPostBackEventReference(this);
107 }
108 #endregion
109 }
110}
111