当前位置:首页 >> 教育精萃
c#js操作命令集合
发布日期:2018-12-24    点击次数:906

【字体: 】  【关闭窗口】  【打印该页】


 protected override void Render(HtmlTextWriter writer)
    {
        System.IO.StringWriter html = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter tw = new System.Web.UI.HtmlTextWriter(html);
        base.Render(tw); System.IO.StreamWriter sw;
        sw = new System.IO.StreamWriter(Server.MapPath("wulilist.html"), false, System.Text.Encoding.UTF8);
        sw.Write(html.ToString());
        sw.Close();
        tw.Close();
        Response.Write(html.ToString());
    }

css里a标签所有内容都是超过一定宽度后隐藏并且变成省略号 。
html中a标签有时候固定一定宽度时,多出来的内容用“...”来代替。必须固定宽度 width: 281px;   
其中overflow: hidden来将多出来的字体隐藏;  
text-overflow: ellipsis;是用来代替的格式;
white-space: nowrap;规定段落中的文本不进行换行
display: block; 必须有       
 width: 281px; white-space: nowrap;
 overflow: hidden; 
text-overflow: ellipsis; 
display: block; 
float: right;


 去掉字符串最后一个字符:c#: ii.Substring(0, ii.Length - 1);
                                                   js: ii.substring(0, ii.length-1);



 var xhr = new XMLHttpRequest();
                         xhr.open('post', "chashiti.aspx?nj=g1");
                        
                         xhr.onload = function (e) {
                             var args = JSON.parse(e.currentTarget.response);
                             alert(args.g1);
                             alert(args.g2);
                             alert(args.g3);
                         }
                        
                         xhr.send()

 json = "{\"g1\":\"" + nj1 + "\",\"g2\":\"" + nj2 + "\",\"g3\":\"" + nj3 + "\"}";



function login() {
             if($("#name").val().trim()==""){
                 alert("请输入您的姓名!");
                 return;
             }
             if ($("#ip").val().trim() == "") {
                 alert("请输入学校给您分配的IP!");
                 return;
             }
             var name=$("#name").val().trim();
             var ip = $("#ip").val().trim();
             $.ajax
    ({
        url: "jslogin.aspx",
        dataType: "text",
        data: { name:name, ip: ip},
        success: function (strValue) {
            if (strValue == "y") {
                alert("认证成功!");
                // window.location.reload();
            }else {
                alert("失败!请重新认证!");
            }
        }
    })
         }
         $(document).ready(function () {
             if ('<%=Session["xm"] %>' != "") {
                 $("#name").val('<%=Session["xm"] %>');
                 $("#ip").val('<%=Session["ip"] %>');
             }
         });



.pull-right {
  1.     float: right!important;


  json = "{\"file\":\""+ leifile3 + "\",\"ys\":\"y\"}";



  var formData = new FormData();
             formData.append("file", files[0]);
//alert(files[0].size);
             var xhr = new XMLHttpRequest();
             xhr.open('post', "saveas.aspx?lei="+lei+"&id="+id);
             xhr.onload = function(e) {
                 var args =JSON.parse(e.currentTarget.response);
                 // 通过返回数据的args中state字段判断上传状态
                 // alert(args.st);
                 if (args.st == "y") {
                     alert("上传成功!");
                     if (args.file != "") {
                         var jiaoanfiletext = args.file.split(',');
                         var jiaoanfiletext2 = "";
                         for (var i = 0; i < jiaoanfiletext.length; i++) {
                             var ii = jiaoanfiletext[i].split('-');
                             var type1 = ii[ii.length - 1].split('.');
                             var type2 = type1[type1.length - 1];
                             if (type2 == "doc" || type2 == "xls" || type2 == "ppt" || type2 == "docx" || type2 == "xlsx" || type2 == "pptx") {
                                 jiaoanfiletext2 += "<li class=\"el-upload-list__item is-success focusing el-list-enter-to\"><!----><a class=\"el-upload-list__item-name\" href='https://view.officeapps.live.com/op/view.aspx?src=/tiku/" + jiaoanfiletext[i] + "' title='点击预览' target='_blank'>" + ii[ii.length - 1] + "<i class=\"el-icon-document\"></i>" +
          "</a><label class=\"el-upload-list__item-status-label\"><i class=\"el-icon-upload-success el-icon-circle-check\"></i></label><i class=\"el-icon-close\" onclick=\"javascript: del('" + id + "','" + jiaoanfiletext[i] + "','" + lei + "file'); \">删除</i></li>";
                             }
                             else {
                                 jiaoanfiletext2 += "<li class=\"el-upload-list__item is-success focusing el-list-enter-to\"><!----><a class=\"el-upload-list__item-name\" href='http://www.hnxcyg.cn/tiku/" + jiaoanfiletext[i] + "' title='不支持预览,请点击下载!' target='_blank'>" + ii[ii.length - 1] + "<i class=\"el-icon-document\"></i>" +
                     "</a><label class=\"el-upload-list__item-status-label\"><i class=\"el-icon-upload-success el-icon-circle-check\"></i></label><i class=\"el-icon-close\" onclick=\"javascript: del('" + id + "','" + jiaoanfiletext[i] + "','" + lei + "file'); \">删除</i></li>";

                             }

                         }
                         obj.innerHTML = "<ul><li>我的上传:</li>" + jiaoanfiletext2 + "<li>&nbsp;</li></ul>";

                     } else {
                         obj.innerHTML = "<ul><li>我的上传:</li><li>&nbsp;</li></ul>";

                     }

                 } else if (args.st == "nn") {
                     alert("文件重名,请重名后再上传!");
                 } else {
                     alert("上传失败,请重新操作!");
                 }

             }
             xhr.send(formData)
          



  var obj = "";
           // alert(id+file+jiaoanfile);
           switch (jiaoanfile) {
               case "jiaoanfile":
                  obj=document.getElementById('<%=jiaoanfile.ClientID%>')
                   break;
               case "xueanfile":
                  obj=document.getElementById('<%=xueanfile.ClientID%>')
                   break;
              case "kejianfile":
                  obj=document.getElementById('<%=kejianfile.ClientID%>')
                   break;
               case "shitifile":
                  obj=document.getElementById('<%=shitifile.ClientID%>')
                   break;
               case "sucaifile":
                  obj=document.getElementById('<%=sucaifile.ClientID%>')
                   break;
           }


strsqltongzu = "SELECT * FROM wulilist WHERE bianma='" + id + "' and ip<>'" + Session["ip"] + "' ORDER BY [time] desc";
           不等于;        asc
 private string writejs(string path,string lei)//获取用户磁盘空间所有文件及目录
    {
        string[] jiaoanfiletext =path.ToString().Trim().Split(',');
        string jiaoanfiletext2 = "";
        string id = Request.QueryString["id"];
        foreach (string i in jiaoanfiletext)
        {
            string[] ii = i.Split('-');
            string[] type1 = ii[ii.Length - 1].ToString().Split('.');
            string type2 = type1[type1.Length - 1].ToString();
            if (type2 == "doc" || type2 == "xls" || type2 == "ppt" || type2 == "docx" || type2 == "xlsx" || type2 == "pptx")
            {
                jiaoanfiletext2 += "<li class=\"el-upload-list__item is-success focusing el-list-enter-to\"><!----><a class=\"el-upload-list__item-name\" href='https://view.officeapps.live.com/op/view.aspx?src=/tiku/" + i.ToString() + "' title='点击预览' target='_blank'>" + ii[ii.Length - 1].ToString() + "<i class=\"el-icon-document\"></i>" +
"</a><label class=\"el-upload-list__item-status-label\"><i class=\"el-icon-upload-success el-icon-circle-check\"></i></label><i class=\"el-icon-close\" onclick=\"javascript: del('" + id + "','" + i.ToString() + "','"+lei+"'); \">删除</i></li>";
            }
            else
            {
                jiaoanfiletext2 += "<li class=\"el-upload-list__item is-success focusing el-list-enter-to\"><!----><a class=\"el-upload-list__item-name\" href='http://www.hnxcyg.cn/tiku/" + i.ToString() + "' title='不支持预览,请点击下载!' target='_blank'>" + ii[ii.Length - 1].ToString() + "<i class=\"el-icon-document\"></i>" +
    "</a><label class=\"el-upload-list__item-status-label\"><i class=\"el-icon-upload-success el-icon-circle-check\"></i></label><i class=\"el-icon-close\" onclick=\"javascript: del('" + id + "','" + i.ToString() + "','"+lei+"'); \">删除</i></li>";
            }

        }
        return jiaoanfiletext2;

引用---
 kejianfile.InnerHtml = "<li>我的上传:</li>" + writejs(ds.Tables["table"].Rows[0]["kejianfile"].ToString().Trim(), "kejianfile") + "<li>&nbsp;</li>";



var obj = document.getElementById('<%=FileUpload1.ClientID%>');

var bianma='<% =Request.QueryString[ "id" ] %>';

  string strsql =
           "insert into wulilist(bianma,usr,biaoti,bxorxx,time,jiaocai,zhang,zhangname,jie,jiaoantext,xueantext,shititext,fansitext) values ('" + bianma + "','" + xm + "','" + ds2.Tables["table2"].Rows[0]["biaoti"].ToString().Trim() + "','" + ds2.Tables["table2"].Rows[0]["bxorxx"].ToString().Trim() + "','" + DateTime.Now.ToString() + "','" + ds2.Tables["table2"].Rows[0]["jiaocai"].ToString().Trim() + "','" + ds2.Tables["table2"].Rows[0]["zhang"].ToString().Trim() + "','" + ds2.Tables["table2"].Rows[0]["zhangname"].ToString().Trim() + "','" + ds2.Tables["table2"].Rows[0]["jie"].ToString().Trim() + "','" + tex1 + "','" + tex2 + "','" + tex4 + "','" + tex5 + "')";
            SqlCommand cmd = new SqlCommand(strsql, con3);     //创建执行
            cmd.ExecuteNonQuery();

 string strsql4 = "update wulilist set time='" + DateTime.Now.ToString() + "',jiaoantext='" + tex1 + "',xueantext='" + tex2 + "',shititext='" + tex4 + "',fansitext='" + tex5 + "' WHERE usr='" + xm + "' and  bianma='" + bianma + "'";
            SqlCommand cmd4 = new SqlCommand(strsql4, con3);     //创建执行
            cmd4.ExecuteNonQuery();

 string strsql2 =
               "SELECT * FROM wulilist WHERE bianma='" + id + "'";
                    SqlDataAdapter da2 = new SqlDataAdapter(strsql2, con);                        //创建适配器
                    DataSet ds2 = new DataSet();                                         //创建数据集
                    int count2 = da2.Fill(ds2, "table2");
                    if (count2 != 0)
                    {
                        jiaocai.Text = ds2.Tables["table2"].Rows[0]["jiaocai"].ToString().Trim();
                        jie.Text = ds2.Tables["table2"].Rows[0]["jie"].ToString().Trim();
                        biaoti.Text = ds2.Tables["table2"].Rows[0]["biaoti"].ToString().Trim();
                        zhang.Text = ds2.Tables["table2"].Rows[0]["zhang"].ToString().Trim();
                        zhangname.Text = ds2.Tables["table2"].Rows[0]["zhangname"].ToString().Trim();
                    }
 ClientScript.RegisterStartupScript(this.GetType(), "", "alert('只能上传 doc, ppt, rar, txt, zip, pdf 格式的文件!');", true);

  string[] allowext ={ ".doc", ".ppt", ".rar", ".txt", ".zip", ".pdf", ".jpg", ".xls", ".pptx", ".docx", ".xlsx", ".png", ".gif", ".psd", ".flv", ".swf", ".dbf" };
                for (int i = 0; i < allowext.Length; i++)
                    if (fileext == allowext[i])
                    {
                        fileok = true;
                    }

 if (Session["name"] != null)
        {}

 if (FileUpload1.HasFile)
        {
  FileUpload1.SaveAs(newpath);
      }

 $.ajax({
                 url: 'chzi.ashx',
                method: 'post',
                 data: formData,
                  contentType: false, // 注意这里应设为false
                  processData: false,
                  //enctype:"multipart/form-data",
                  cache: false,
                  success: function (strValue) { //登录成功后返回的数据
                      //根据返回值进行状态显示
                      if (strValue == "y") {
                          alert("更新成功!");
                          // window.location.reload();
                      }
                      else if (strValue == "n") {
                          alert("保存成功!");
                      } else {
                          alert(strValue);
                      }
                  }
               })

 $.ajax
  ({ //请求登录处理页
      url: "chuanzhi.aspx", //登录处理页
      dataType: "text",
      //传送请求数据
      data: { bianma: bianma, tex1: tex1, tex2: tex2, tex4: tex4, tex5: tex5 },
      success: function (strValue) { //登录成功后返回的数据
          //根据返回值进行状态显示
          if (strValue == "y") {
              alert("更新成功!");
             // window.location.reload();
          }
          else if (strValue == "n")
          {
              alert("保存成功!");
          }else
          {
              alert("失败!请重新操作!");
          }
      }
  })
相关阅读