当前位置:  编程技术>.net/c#/asp.net
本页文章导读:
    ▪IE下document.referrer 拒绝访问的解决方法       用document.referrer回到来源页(也可以称作上一页)时非常方面,我们不用知道来源页复杂的url,而且document.referrer回到来源页时会重新加载,而不是上一次的状态,所以说非常的方便。 但是在.........
    ▪GridView自定义删除操作的具体方法       首先,我们前端的代码如下: 代码如下:<asp:GridView ID="gridViewDxjk" Css runat="server" AllowPaging="True"                   DataKeyNames="P_ID" AutoGenerateColumns="False"                     .........
    ▪asp.net Textbox服务器控件       代码如下:<body>    <form id="form1" runat="server">    <div>        姓名:<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>        <br />        <br />        .........

[1]IE下document.referrer 拒绝访问的解决方法
    来源: 互联网  发布时间: 2013-11-30
用document.referrer回到来源页(也可以称作上一页)时非常方面,我们不用知道来源页复杂的url,而且document.referrer回到来源页时会重新加载,而不是上一次的状态,所以说非常的方便。

但是在IE中用javascript做跳转,比如用window.location.href=/blog_article/“”;/index.html 跳转到的页面无法取到浏览器请求的HTTP referrer,IE浏览器会报脚本错误“拒绝访问”,因为IE清空了document.referrer。

而其他主流浏览器Firefox和Chrome都会保留referrer,这意味着IE又要享受“部长级”特殊待遇了:
代码如下:

var referLink = document.createElement('a');
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();

这样的原理就是给IE浏览器的页面偷偷加了个链接,然后自动点这个链接,于是referrer就能保留了。

    
[2]GridView自定义删除操作的具体方法
    来源: 互联网  发布时间: 2013-11-30

首先,我们前端的代码如下:

代码如下:

<asp:GridView ID="gridViewDxjk" Css runat="server" AllowPaging="True"
                  DataKeyNames="P_ID" AutoGenerateColumns="False" 
                      RowStyle-HorizontalAlign="Center" BorderWidth="1px" PageSize="17"
                      onrowdeleting="gridViewDxjk_RowDeleting"
                      OnRowDataBound="gridViewDxjk_RowDataBound"
                      onpageindexchanging="gridViewDxjk_PageIndexChanging" >
                        <HeaderStyle Css />
                        <PagerStyle Css />
                        <RowStyle Css />
                        <EditRowStyle Css />
                        <AlternatingRowStyle Css />
                        <EmptyDataRowStyle Css />
                        <Columns>                           
                         <asp:HyperLinkField HeaderText="编辑" ControlStyle-Width="50" DataNavigateUrlFields="P_ID" DataNavigateUrlFormatString="smsModify.aspx?id={0}" Text="编辑"  >
                                <ControlStyle Width="50px"></ControlStyle></asp:HyperLinkField>
                                <asp:CommandField  ShowDeleteButton="true" DeleteText="删除"   >
                                <ControlStyle Width="50px"></ControlStyle></asp:CommandField>
                                <asp:BoundField DataField="P_ID" HeaderText="id" SortExpression="P_ID" ItemStyle-HorizontalAlign="Center"  Visible="False" >
                                <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
                                <asp:BoundField DataField="P_NAME" HeaderText="名称" SortExpression="P_NAME" />
                                <asp:BoundField DataField="P_Type" HeaderText="通知方式" SortExpression="P_Type" ItemStyle-HorizontalAlign="Center"  >
                                <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
                                <asp:BoundField DataField="P_Fzr" HeaderText="姓名" SortExpression="P_Fzr" ItemStyle-HorizontalAlign="Center"  >
                                <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
                                <asp:BoundField DataField="P_tel" HeaderText="通知手机" SortExpression="P_tel" ItemStyle-HorizontalAlign="Center"  >
                                <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
                                <asp:BoundField DataField="P_jg" HeaderText="通知间隔(小时)" SortExpression="P_jg" ItemStyle-HorizontalAlign="Center"  >
                                <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
                                <asp:BoundField DataField="P_on" HeaderText="是否开启" SortExpression="P_on" ItemStyle-HorizontalAlign="Center"  >
                                <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
                                <asp:BoundField DataField="P_lasttime" HeaderText="最后发送时间" SortExpression="P_lasttime" ItemStyle-HorizontalAlign="Center"  >
                                <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
                                <asp:BoundField DataField="P_memo" HeaderText="备注" SortExpression="P_memo" ItemStyle-HorizontalAlign="Center"  >                  
                                <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
                        </Columns>
                        <EmptyDataTemplate>
                        没有数据!
                        </EmptyDataTemplate>
                         <PagerTemplate>
                        <table width="100%" >
                            <tr>
                            <td >
                                第<asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>'></asp:Label>页
                                /共<asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount %>'></asp:Label>页  
                              <asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page" Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">首页</asp:LinkButton>
                              <asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page"  Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">上一页</asp:LinkButton>
                              <asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page"  Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">下一页</asp:LinkButton>
                              <asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page"  Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">尾页</asp:LinkButton>
                              <asp:TextBox ID="txtNewPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>'  Width="20px" AutoPostBack="true" ></asp:TextBox>
                              <asp:LinkButton ID="btnGoEx" runat="server" CommandArgument="GO" CommandName="Page" Text="GO" OnClick="btnGoEx_Click"></asp:LinkButton>
                            </td>
                            </tr>
                        </table>
                    </PagerTemplate>
                 </asp:GridView>

后端的话,由于需要弹出删除前的确认框,所以,我们需要在RowDataBound里面做点什么?同时,要想真正的删除,还需要触发RowDeleting事件,具体代码如下:

代码如下:

//报警删除
        protected void gridViewDxjk_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string key = gridViewDxjk.DataKeys[e.RowIndex].Value.ToString();
            bool flag = bll.Delete(Int32.Parse(key));
            if (flag)
                NXT_WLService.App_Code.JScript.Alert("删除成功!", this);
            else
                NXT_WLService.App_Code.JScript.Alert("删除失败!", this);
        }

       
        protected void gridViewDxjk_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton btn = (LinkButton)e.Row.Cells[1].Controls[0];
                if (btn.Text.Equals("删除"))//刪除鈕才加提示訊息 
                    btn.OnClientClick = "if (confirm('你确认要删除?')) javascript:__doPostBack('gridViewDxjk','Delete$" + e.Row.RowIndex.ToString() + "'); else return false;";
            }
        }


    
[3]asp.net Textbox服务器控件
    来源: 互联网  发布时间: 2013-11-30

代码如下:

<body>
    <form id="form1" runat="server">
    <div>

        姓名:<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
        <br />
        <br />
        性别:<asp:RadioButtonList ID="rblsex" runat="server">
            <asp:ListItem>男</asp:ListItem>
            <asp:ListItem>女</asp:ListItem>
        </asp:RadioButtonList>
        密码:<asp:TextBox ID="txtPwd" runat="server" TextMode="Password"></asp:TextBox>
        <br />
        移动电话:<asp:TextBox ID="txttel" runat="server"
            ontextchanged="TextBox3_TextChanged"></asp:TextBox>
        <br />
        简介:<br />
        <asp:TextBox ID="txtinfo" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:ImageButton ID="ImageButton1" runat="server" Height="58px"
            ImageUrl="~/img/QQ截图20130909140346.png" Width="72px" />
        <br />
        <br />
        <br />
        <br />
        <br />

    </div>
    </form>
</body>


textChange的事件代码如下:

代码如下:

protected void txtNum2_TextChanged(object sender, EventArgs e)
    {
        if (txtNum2.Text.Length == 0)
        {
            //Page.RegisterClientScriptBlock("","<script>alert('请输入一个数');</script>");
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('请输入一个数');</script>");
            txtNum2.Focus();
        }
        else
        {
            int result;
            bool n1 = Information.IsNumeric(txtNum2.Text.Trim());
            if (n1)
            {
                result = int.Parse(txtNum2.Text.Trim()) % 2;
                if (result == 0)
                {
                    txtSum.Text = "偶数";
                }
                else
                {
                    txtSum.Text = "奇数";
                }
            }
        }
    }
}

    
最新技术文章:
▪C#通过IComparable实现ListT.sort()排序
▪C#实现对Json字符串处理实例
▪Winform实现抓取web页面内容的方法
▪Winform实现将网页生成图片的方法
▪C#控制台程序中处理2个关闭事件的代码实例
▪WinForm实现同时让两个窗体有激活效果的特效...
▪C#控制台程序中处理2个关闭事件的代码实例 iis7站长之家
▪用C#的params关键字实现方法形参个数可变示例
▪C#判断某程序是否运行的方法
▪C#验证码识别基础方法实例分析
▪C#通过WIN32 API实现嵌入程序窗体
▪C#实现获取鼠标句柄的方法
▪C#事件处理和委托event delegate实例简述
▪C#获取程序文件相关信息的方法
▪C#中的除法运算符与VB.NET中的除法运算符
▪ASP.NET MVC 5使用X.PagedList.Mvc进行分页教程(PagedLi...
▪Base64编码解码原理及C#编程实例
▪C#实现的优酷真实视频地址解析功能(2014新算...
▪C#和SQL实现的字符串相似度计算代码分享
▪C#使用Word中的内置对话框实例
▪C#反射之基础应用实例总结
▪C#生成单页静态页简单实例
▪C#实现SMTP邮件发送程序实例
▪C#实现随鼠标移动窗体实例
▪C#使用GDI+创建缩略图实例
▪C#实现通过模板自动创建Word文档的方法
▪C#中Response.Write常见问题汇总
▪C#中多态、重载、重写区别分析
▪WinFrom中label背景透明的实现方法
▪C#中out保留字用法实例分析
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3