📄 logincs.aspx
字号:
<%@ Page CodeBehind="LoginCS.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="Telerik.EditorExamplesCSharp.Editor.Examples.Security.LoginCS" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" Assembly="Telerik.QuickStart" %>
<%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
<%@ Register TagPrefix="radE" Namespace="Telerik.WebControls" Assembly="RadEditor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head runat="server">
<telerik:HeadTag runat="server" ID="Headtag1"></telerik:HeadTag>
</head>
<body class="BODY">
<form runat="server" id="mainForm" method="post" style="width:774px;text-align:left;margin-top:20px;">
<script language="javascript">
//<![CDATA[
function showDiv(div)
{
var el = document.getElementById(div);
el.style.display = (el.style.display == 'none') ? 'block' : 'none';
document.getElementById(div == "csharp" ? "vbasic" : "csharp").style.display = "none";
}
//]]>
</script>
<div><asp:Label id="Message" runat="server" CssClass="text"><b> r.a.d.<b>editor</b> security example login:</b></asp:Label><br/><br/></div>
<table class="module" style="width:300px;height:140px;">
<tr>
<td align="left" colspan="2">
Username: <b>admin</b> Password: <b>admin</b><br/>
</td>
</tr>
<tr>
<td><b>Username</b></td>
<td>
<asp:textbox id="username" Runat="server" Width="120" />
</td>
</tr>
<tr>
<td><b>Password</b></td>
<td>
<asp:textbox id="password" Runat="server" Width="120" TextMode="password" />
</td>
</tr>
<tr>
<td></td>
<td>
<asp:button id="submitButton" Runat="server" Text="Login" CssClass="button"/>
</td>
</tr>
</table>
<div style="display:inline;"><br/>
<span class="text">
telerik
r.a.d.<b>editor</b> has built-in mechanisms for enforcing
security and roles in multi-user environments. This allows easy integration even in large enterprise-wide systems.<br/>
The editor can be dynamically configured to reflect what a particular user can or cannot do.
In order to implement such dynamic configuration you need to do the
following:
<br/> 1) Detect that a particular user is logged into the system<br/>
2) Dynamically set the editor's properties in your Page_Load
method<br/><br/>
<span class="title"><b>Sample Scenario</b><br/>
</span>The present example uses the .NET <b>Forms authentication</b> mechanism.
To make it work you need to add a couple of lines must be added to the <b>Web.config</b> file of the application.<br/><br/>
The page C# code "logs in" one of two possible users called <b>admin</b> and <b>superadmin</b>, and then directs the logged user to a page with a
r.a.d.<b>editor</b>.
The editor is configured differently, depending on the user who is logged in.
<br/>
<a href="#" onclick="showDiv('csharp'); return false;">View C# Login Code</a></span></div>
<div id="csharp" style="display:none;font-family:Monospace;font-size:8pt">
<b>C#:</b>
<pre>
private void submitButton_Click(object sender, System.EventArgs e)
{
if( FormsAuthentication.Authenticate(username.Text, password.Text))
{
FormsAuthentication.SetAuthCookie(username.Text, false);
Response.Redirect ("./DefaultCS.aspx");
}
else
{
Message.Text = "Please provide valid username and password";
}
}
</pre>
</div>
<div style="display:inline;"><br/>
<a href="#" onclick="showDiv('vbasic'); return false;">View VB Login Code</a></div>
<div id="vbasic" style="display:none;font-family:Monospace;font-size:8pt">
<b>VB:</b>
<pre>
Private Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
If FormsAuthentication.Authenticate(username.Text, password.Text) Then
FormsAuthentication.SetAuthCookie(username.Text, False)
Response.Redirect("./DefaultVB.aspx")
Else
Message.Text = "Please provide valid username and password"
End If
End Sub
</pre>
</div>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -