ASP.NET学习笔记 1

 

一、      关于DataGrid的分页
除了设置:

AllowPaging是指允许分页,这个是最主要的。有了它,我们才能分页。

PageSize是指定每页显示的记录数,如果不写,就会默认为10条。

外,还要加入:

       OnPageIndexChanged="DataGrid1_PageIndexChanged"

       public void DataGrid1_PageIndexChanged(object sender, DataGridPageChangedEventArgs e)

              {

                     DataGrid1.CurrentPageIndex =e.NewPageIndex;

                     DataGrid1.DataBind();

              } 


二、      关于上传文件
上传文件应加入:

       <form id="Form1" enctype="multipart/form-data" method="post" runat="server">

源文件里边加入:

       if(File1.PostedFile !=null)

                     {

                            File1.PostedFile.SaveAs (Server.MapPath ("\\1.jpg"));

                            Image1.ImageUrl =Server.MapPath ("\\1.jpg");                           

                     } 


三、      关于自动刷新
HTML应加入:

       <meta http-equiv ="REFRESH" content ="10;URL=chat.aspx">

自动窗口ScrollWindow():

       <script language =javascript 1.1>

              function scrollWindow()

              {

                     this.scroll(0,65000);

                     setTimeout('scrollWindow()',200);

              }

              scrollWindow();

       </script> 

四、      连到SQL数据库
                     string _sql;

                     SqlConnection cn;

                     _sql="server=localhost;uid=sa;pwd=hz0222;database=Northwind";

                     cn=new SqlConnection (_sql);

                     cn.Open ();

                     //SqlCommand cmd =new SqlCommand ("select * from Products ",cn);

                     //SqlDataReader rs;

                     //rs=cmd.ExecuteReader();

                     SqlDataAdapter da=new SqlDataAdapter ("select * from Products",cn);

                     DataSet ds=new DataSet ();

                     da.Fill (ds,"Products");

                     DataGrid1.DataSource =ds.Tables["Products"].DefaultView ;

                     //DataGrid1.CurrentPageIndex = 0;

                     DataGrid1.DataBind ();

                     cn.Close ();


五、      查询IP地址
              private void Button6_Click(object sender, System.EventArgs e)

              {

                     IPHostEntry hostInfo = Dns.GetHostByName(txtDomain.Text);

                     Response.Write ("<br>" +hostInfo.AddressList[0].ToString());

              }

       当然记得用引名字空间 System.Net 


六、      在HTML中加载处理页面
       <form method="post" action="index2.aspx"> 


七、      使用TreeView控件
a)    下载并安装IEWebControls:http://www.asp.net/IEWebControls/Download.aspx

b)    安装完以后,默认状态下会建立一个目录:\Program files\IEWeb Controls\,当然你也可改变安装目录。找到这个目录,双击build.bat文件执行,它会建立一个名为build的子目录,并且编译在src目录下的源文件,把编译结果和Runtime目录复制到build子目录中(自动)。在这个动作之后,在build目录下应该会有一个叫"Microsoft.Web.UI.WebControls.dll"文件和一个Runtime子目录。为了能在ASP.NET的Web应用程序中使用这个控件,你必须把\build\Runtime子目录下的内容复制到Web应用程序的 /webctrl_client/1_0子目录中,并且把"Microsoft.Web.UI.WebControls.dll"这个文件复制到Web应用程序的/bin目录下。这个过程在Readme.txt文件有详细的说明,不过是英文的。

c)    然后,你就可以在Toolbox中添加一个工具了(这个不用说明了吧)

d)    以下是WebControls的说明书(E文)      

To run the IE Web Controls: 


1.  Copy the contents of the Runtime directory to the webctrl_client\1_0

    directory under your top-level site directory.  For example, if your

    site root is c:\Inetpub\wwwroot, type this at the command prompt:

    xcopy /s /i .\build\Runtime c:\Inetpub\wwwroot\webctrl_client\1_0 /y

    This will create the following directory structure under the site:

      /webctrl_client/1_0

        MultiPage.htc

        TabStrip.htc

        toolbar.htc

        treeview.htc

        webservice.htc

        webserviced.htc

        [images]

        [treeimages]


2.  Create a new web application in IIS and copy the contents of the

    samples directory to this application directory.  For example:

    xcopy /s /i .\samples c:\Inetpub\wwwroot\sampleapp /y 


3.  Create a /bin subdirectory for the application and copy the file

    Microsoft.Web.UI.WebControls.dll to this directory.

    The contents of the application will be as follows:

      /sampleapp

        multipage.aspx

        state_city.xml

        tabstrip.aspx

        toolbar.aspx

        treeview.aspx

        treeview_bound.aspx

        /bin

          Microsoft.Web.UI.WebControls.dll

4.  Request the sample pages from your Internet Explorer web browser, for

    example: http://localhost/sampleapp/multipage.aspx 


八、      取消IE内容安全验证
a)    validateRequest="false"

九、      第三方的Dtable控件使用方法
a)    一定要把HTML中的<form……去掉

b)    所连接的表的第一个字段必需是自动编号的int类型,Sql的验证最好加上ASP.NET这个帐号

c)    其它问题请参考论坛http://dtable.2smm.com 

转载于:https://www.cnblogs.com/BoKeRen/archive/2006/03/01/340294.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值