码迷,mamicode.com
首页 > Web开发 > 详细

asp.net页面整理

时间:2015-03-15 12:08:16      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

页面模板

把html内容在一般处理程序里添加

  public void ProcessRequest(HttpContext context) { 
  context.Response.ContentType = "text/html";
context.Response.Write("<html>");
context.Response.Write("<head></head>"); //\="login.ashx"
context.Response.Write(@"<body><form action=‘login.ashx‘>用户名:<input type=‘text‘ name=‘username‘ /><br />
     密码 <input type=‘text‘name=‘pwd‘ /><br /><input type=‘submit‘ value=‘登录‘ /></form></body>");    
        context.Response.Write("</html>");  }

把输出的html 代码写成字符串

  public void ProcessRequest(HttpContext context) {
   context.Response.ContentType = "text/html";
   string username = context.Request["username"]; 
   string pwd = context.Request["pwd"]; 
   string html="<html>"+"<head></head>"+"<body><form action=‘login.ashx‘>" +  
                "<font color=‘red‘> 用户名:<font><input type=‘text‘ name=‘username‘ value=‘{username}‘/><br/>" +
               "<font color=‘red‘> 密码:<font><input type=‘text‘ name=‘pwd‘ value=‘{pwd}‘/><br/>" +
               "<input type=‘submit‘ value=‘登录‘ /><p>{msg}</p>"+
                "</form></body>"+"<html>"; 
   if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(pwd)) 
      {  context.Response.Write("</html>");       
          string code = html.Replace("{username}", "");   
          code=  code.Replace("{passord}","");         
        context.Response.Write(code);
     }
     else            
       {    if (username == "admin" && pwd == "123")    
             { context.Response.Redirect("DOM.html"); }    
             else                
             { string code = html.Replace("{username}", username);   
                code=  code.Replace("{passord}", pwd);         
              code = code.Replace("{msg}", "你输入的账号和密码不对");   
                  context.Response.Write(code);                                         //context.Response.Write("你输入的账号和密码不对");                 }                              
        }                       
}

asp.net页面整理

标签:

原文地址:http://www.cnblogs.com/zm-james/p/4338963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!