zoukankan      html  css  js  c++  java
  • html静态文件提交到aspx页面处理

    以前曾经尝试过,但是失败,最近才发现的。

    关键在html中:

    如果元素被提交到aspx后台,元素必须至少有name属性:<input type="text" name="txtName" />

    后台访问时候的方法是  string name = Request.Form["txtName"];    

    html文件:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head></head>

    <body>  

     <center>    

       <br />        <br />      

     <div>        

       在此处输入,页面提交到了WebForm3.aspx中。        

       <br />        

       <span style="color: Red;">提交的窗体中的控件若被后台访问到则“一定要有name属性,是否有id属性无所谓”</span>

    </div>      

     <form action="WebForm3.aspx" method="post">  

         <div>            name:<input id="txtName" name="txtName" type="text" /><span id="CheckName"></span></div>  

         <div>            pwd:            <input name="txtPwd" type="password" /></div>    

       <div>            city:            <select name="selectCity">                <option value="beijing">北京</option>                <option value="shanghai">上海</option>            </select>        </div>      

     <div>            sex:            <input type="radio" name="radioSex" value="male" />男&nbsp;&nbsp;            <input type="radio" name="radioSex" value="female" />女</div>      

     <div>            <input id="file1" name="file1" type="file" /></div>        <input id="Submit1" type="submit" value="submit" />    

       </form>    </center></body></html>

    WebForm3.aspx.cs文件:

            protected void Page_Load(object sender, EventArgs e)    

       {  

             string name = Request.Form["txtName"];    

           string pwd = Request.Form["txtPwd"];    

           string city = Request.Form["selectCity"];  

             string sex = Request.Form["radioSex"]; 

               string file = Request.Form["file1"];      

         Response.Write("您输入了:" + name + "<br />"+pwd+"<br />"+city+"<br />"+sex+"<br />"+file+"<br />");                        Response.Write(DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"));    

       }

  • 相关阅读:
    git 比较两个分支日志和文件的差异
    Interspeech 2020调研:文本前端
    centOS 7 修改分辨率、图形与命令行界面切换
    pdf表格提取camelot安装教程
    CFS任务的负载均衡——2
    CFS任务的负载均衡(框架篇)——(1)
    ftrace笔记一
    红黑树rbtree学习笔记
    一. scheduler相关结构体简介
    cpu_capacity、task_util、cpu_util计算方法
  • 原文地址:https://www.cnblogs.com/mazhlo/p/2003975.html
Copyright © 2011-2022 走看看