Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx

上传人:b****1 文档编号:1162925 上传时间:2023-04-30 格式:DOCX 页数:13 大小:17.86KB
下载 相关 举报
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第1页
第1页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第2页
第2页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第3页
第3页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第4页
第4页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第5页
第5页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第6页
第6页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第7页
第7页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第8页
第8页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第9页
第9页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第10页
第10页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第11页
第11页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第12页
第12页 / 共13页
Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx_第13页
第13页 / 共13页
亲,该文档总共13页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx

《Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx》由会员分享,可在线阅读,更多相关《Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx(13页珍藏版)》请在冰点文库上搜索。

Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码.docx

Aspnet常用经典考试代码富文本框登陆验证码添加信息上传功能图片显示代码浏览器上出现图标等代码

Asp考试常用代码

富文本框,登陆,验证码,添加信息,上传功能,图片显示代码,浏览器上出现图标等代码

发微薄代码aspx

ContentID="Content1"ContentPlaceHolderID="head"Runat="Server">

//用js判断当前还可以输入多少字

functioncountChar(){

vari=140-document.getElementById("ContentPlaceHolder1_ListView1_neirongTextBox").value.length;

if(i>=0){

vari=document.getElementById("bq").innerHTML="还可以输入";document.getElementById("span1").innerHTML=140-document.getElementById("ContentPlaceHolder1_ListView1_neirongTextBox").value.length;

document.getElementById("span2").innerHTML="字";

}

elseif(i<0){

vari=document.getElementById("bq").innerHTML="超出";document.getElementById("span1").innerHTML=-140+document.getElementById("ContentPlaceHolder1_ListView1_neirongTextBox").value.length;

document.getElementById("span2").innerHTML="个文字请删除";}

};

富文本框

--

bkLib.onDomLoaded(function(){

newnicEditor({fullPanel:

true}).panelInstance('ContentPlaceHolder1_ListView1_neirongTextBox');

});

-->

Content>

上传功能

FileUploadID="FileUpload1"runat="server"/>

ButtonID="Button1"runat="server"Text="上传文件"onclick="Button1_Click"/>

ListView控件配置

ListViewID="ListView1"runat="server"DataKeyNames="id"

DataSourceID="AccessDataSource1"InsertItemPosition="LastItem"OnDataBound="ListView1_DataBound">

未返回数据


  • 我要发言

    --

    DropDownListSelectedValue='<%#Bind("yid")%>'ID="yidDropDownList1"runat="server"DataSourceID="AccessDataSource2"DataTextField="yonghu"DataValueField="yid">

    DropDownList>!

    -->

    TextBoxID="yidTextBox"Text='<%#Bind("yid")%>'runat="server">

    TextBox>



  • block;font-family:

    华文琥珀;font-size:

    large;font-style:

    italic;font-variant:

    small-caps;text-transform:

    capitalize;color:

    #FF0000;">有啥新鲜事想跟大家分享?

    可以输入140

    TextBoxmaxlength="140"ID="neirongTextBox"rows="2"cols="20"name="neirongTextBox"onkeydown="countChar()"onkeyup="countChar()"runat="server"Text='<%#Bind("neirong")%>'ViewStateMode="Inherit"TextMode="MultiLine"Width="400px"Height="180px"/>

    --时间-->

    HiddenFieldID="timeTextBox"runat="server"Value='<%#Bind("time")%>'/>


    ButtonID="InsertButton"runat="server"CommandName="Insert"Text="发微博"Height="30"Width="50"Enabled="True"/>

    ButtonID="CancelButton"runat="server"CommandName="Cancel"Text="重填"Height="30"Width="50"/>



    ListView>

    发微薄cs

    usingSystem;

    usingSystem.Collections.Generic;

    usingSystem.Linq;

    usingSystem.Web;

    usingSystem.Web.UI;

    usingSystem.Web.UI.WebControls;

    publicpartialclassfaweibo:

    System.Web.UI.Page

    {

    protectedvoidPage_Load(objectsender,EventArgse)

    {

    }

    protectedvoidListView1_DataBound(objectsender,EventArgse)

    {

    HiddenFieldsj=(HiddenField)ListView1.InsertItem.FindControl("timeTextBox");

    sj.Value=System.DateTime.Now.ToString();

    TextBoxyid=(TextBox)ListView1.InsertItem.FindControl("yidTextBox");

    if(Session["yid"]==null)

    {

    yid.Text="4";

    }

    else

    {

    yid.Text=Session["yid"].ToString();

    }

    }

    protectedvoidButton1_Click(objectsender,EventArgse)

    {

    if(FileUpload1.HasFile)

    {

    stringfileName=FileUpload1.FileName;

    //定义上传文件的扩展名

    stringfileExtent=System.IO.Path.GetExtension(fileName);

    //重新命名文件

    fileName=DateTime.Now.ToString("yyyyMMddhhmmss")+fileExtent;

    stringfx=".jpg,.jpeg,.gif,.bmp,.png";

    if(fx.IndexOf(fileExtent)==-1)

    {

    Label1.Text="你上传的不是图片文件";

    return;

    }

    //限制图片大小

    intfileSize=FileUpload1.PostedFile.ContentLength;

    if(fileSize>102400)

    {

    Label1.Text="图片文件太大,不能超过100KB";

    return;

    }

    stringfilePath=Server.MapPath("up/");

    FileUpload1.SaveAs(filePath+fileName);

    //得到url的地址

    stringstrurl=Request.Url.ToString();

    stringstrFileDownloadPath=strurl.Substring(0,strurl.LastIndexOf('/'))+"/up/"+fileName;

    Label1.Text=strFileDownloadPath;

    }

    }

    }

    登陆aspx

    ContentID="Content2"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

    LabelID="Label8"runat="server"Text="">

    Label>


    用户名:

    TextBoxID="UsernameTextBox"runat="server">

    TextBox>


    密码:

     nbsp;

    TextBoxID="PasswordTextBox"runat="server"TextMode="Password">

    TextBox>


    LabelID="Label7"runat="server"Text="">

    Label>


    验证码:

    TextBoxID="CheckCodeTextBox"runat="server"Width="72px">

    TextBox>



    LabelID="Label6"runat="server"Text="Label">

    Label>

    LinkButtonID="LinkButton2"runat="server"onclick="LinkButton2_Click">看不清

    LinkButton>

    --

    ImageID="Image1"runat="server"ImageUrl="~/YanZhengMa.aspx"/>

    '+newDate().getTime();returnfalse;"">看不清楚
    -->


    ButtonID="Button1"runat="server"Text="登陆"onclick="Button1_Click"/>


    LabelID="Label1"runat="server">

    Label>

    Content>

    登陆cs

    usingSystem;

    usingSystem.Collections.Generic;

    usingSystem.Linq;

    usingSystem.Web;

    usingSystem.Web.UI;

    usingSystem.Web.UI.WebControls;

    usingSystem.Data.OleDb;

    publicpartialclasslogin:

    System.Web.UI.Page

    {

    protectedvoidPage_Load(objectsender,EventArgse)

    {

    if(!

    Page.IsPostBack)

    {

    Label6.Text=CheckCode();

    }

    }

    protectedvoidButton1_Click(objectsender,EventArgse)

    {

    //首先验证用户输入的验证码?

    if(CheckCodeTextBox.Text!

    =Session["cc"].ToString())

    {

    Label8.Text="";

    Label7.Text="验证码输入错误!

    ";

    //重新生成验证码?

    return;

    }

    else

    {

    Label8.Text="";

    Label7.Text="验证通过";

    stringUsername=UsernameTextBox.Text.ToString();

    stringPassword=PasswordTextBox.Text.ToString();

    stringyid;

    using(OleDbConnectionconn=newOleDbConnection())

    {

    conn.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=H:

    \schoolwork\ASP.NET\大二下\陈历生第十一周\App_Data\weibo.mdb";

    conn.Open();

    using(OleDbCommandcmd=newOleDbCommand())

    {

    cmd.CommandText="selectyidfromyonghuwhereyonghu='"+Username+"'andPassword='"+Password+"'";

    cmd.Connection=conn;

    yid=cmd.ExecuteScalar()==null?

    "":

    cmd.ExecuteScalar().ToString();

    //判断id没有情况下还回为空,有就还回cmd.ExecuteScalar().ToString();

    }

    }

    if(yid==null||yid=="")

    {

    Label7.Text="";

    Label8.Text="用户或密码错误!

    请重新输入!

    ";

    }

    else

    {

    Session["yid"]=yid;

    Session["yonghu"]=Username;

    Label7.Text="";

    Label8.Text="用户登录成功?

    ";

    }

    return;

    }

    }

    //生成新的验证码

    protectedstringCheckCode()

    {

    char[]ss={'a','b','c','d','e','f','0','1','g','h','i','j','k','l','m','n','v','z','f','s','p','u','y','t','r','3','4','5','6','7','8','9'};

    Randomrnd=newRandom();

    stringcc="";

    for(inti=0;i<4;i++)

    {

    //cc+=rnd.Next(10);

    //cc=cc+rnd.Next(10);

    cc+=ss[rnd.Next(ss.Length)];

    }

    Session["cc"]=cc;

    returncc;

    }

    protectedvoidLinkButton2_Click(objectsender,EventArgse)

    {

    //看不清点击重新生成验证码?

    Label6.Text=CheckCode();

    }

    }

    显示图片代码

    imageWidth="30px"Height="30px"ID="touxiangimage"runat="server"imageurl='<%#Eval("touxiang")%>'/>

    Web.config文件修改

    xmlversion="1.0"?

    >

    --

    有关如¨何配置ASP.NET应用程序¨的详细信息,请访问º

    -->

    浏览器上出现ICO图标

    --浏览器上出现ICO图标-->

    上传文件aspx

    FileUploadID="FileUpload1"runat="server"/>

    ButtonID="Button1"runat="server"Text="文件上传"onclick="Button1_Click"/>


    LabelID="Label2"runat="server"Text="Labe2">

    Label>

    上传文件cs

    usingSystem;

    usingSystem.Collections.Generic;

    usingSystem.Linq;

    usingSystem.Web;

    usingSystem.Web.UI;

    usingSystem.Web.UI.WebControls;

    publicpartialclass_Default:

    System.Web.UI.Page

    {

    protectedvoidPage_Load(objectsender,EventArgse)

    {

    }

    protectedvoidButton1_Click(objectsender,EventArgse)

    {

    if(FileUpload1.HasFile)

    {

    stringfileName=FileUpload1.FileName;

    //定义上传文件的扩展名

    stringfileExtent=System.IO.Path.GetExtension(fileName);

    //重新命名文件

    fileName=DateTime.Now.ToString("yyyyMMddhhmmss")+fileExtent;

    stringfx=".jpg,.jpeg,.gif,.bmp,.png";

    if(fx.IndexOf(fileExtent)==-1)

    {

    Label2.Text="你上传的不是图片文件";

    return;

    }

    //限制图片大小

    intfileSize=FileUpload1.PostedFile.ContentLength;

    if(fileSize>102400)

    {

    Label2.Text="图片文件太大,不能超过100KB";

    return;

    }

    stringfilePath=Server.MapPath("up/");

    FileUpload1.SaveAs(filePath+fileName);

    //得到url的地址

    stringstrurl=Request.Url.ToString();

    stringstrFileDownloadPath=strurl.Substring(0,strurl.LastIndexOf('/'))+"/Upload/"+fileName;

    Label2.Text=strFileDownloadPath;

    }

    }

    }

    展开阅读全文
    相关资源
    猜你喜欢
    相关搜索
    资源标签

    当前位置:首页 > 人文社科 > 法律资料

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2