后台
namespace WebApplication17
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
///
/// 生成软键盘的用户控件
/// 于10月21日河北鼎新公司B2C部开发
///
public class
<%=stra%>
后台
namespace WebApplication17
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
///
/// 生成软键盘的用户控件
/// 于10月21日河北鼎新公司B2C部开发
///
public class WebUserControl2 : System.Web.UI.UserControl
{
public static string stra="";//用于前台生成软键盘的字符串
public static string str1="";//获得随机排序号的字符串
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
stra=GreateTb();
}
#region 生成软键盘
///
/// 生成软键盘字符串
///
///
生成建立软键盘的HTML字符串
private string GreateTb()
{
string str="\n";
string[] strg={"BackSpace","Enter","切换大/小写","当前是小写","="};
string[] ctr={"setpassvalue()","closekeyboard()","setCapsLock()","","addvalue('=')"};
str1=CreateRandomCode1();
for(int i=0;i<=4;i++)
{
str+="\n";
for(int j=i;j<=10+i;j++)
{
str+="\n";
}
str+="\n";
str+="\n";
}
str+="
\n";
return str;
}
#endregion
#region 对字符串随机排序
///
/// 对字符串随机排序
///
///
排序后的字符串
private string CreateRandomCode1()
{
string allChar = "abcdefghijklmnopqrstuvwxyz" ;
string allChar1="-_:[]<>()~!@#$%`&*?.";
string allChar2="1234567890";
string randomCode = "";
Random rand = new Random();
for(int i = 0; i <= 25; i++)
{
int t = rand.Next(allChar.Length-1);
randomCode+=allChar[t];
allChar=allChar.Remove(t,1);
}
for(int i = 0; i <= 19; i++)
{
int t = rand.Next(allChar1.Length-1);
randomCode+=allChar1[t];
allChar1=allChar1.Remove(t,1);
}
for(int i = 0; i <= 9; i++)
{
int t = rand.Next(allChar2.Length-1);
randomCode+=allChar2[t];
allChar2=allChar2.Remove(t,1);
}
return randomCode;
}
#endregion
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}