易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net页面中动态地添加javascript脚本

最近的项目开发中 遇到一些需要根据具体情况动态添加javaScript脚本,然后执行脚本 于是收集了一下:
1 在控件的绑定事件中添加脚本 如:在gridview控件的rowdatabind事件中可以实现 指针的选中行不同色显示 可添加脚本
  protected void gvEngineerRepairState_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='99ccff'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''");
            }
        }
2 在后置代码类中 还可以给控件注册脚本:
   ScriptManager.RegisterStartupScript(btnPrint, this.GetType(), "onclick", "<script language='javascript'>window.open('../PrintTest/PrintBack.aspx?pname=" + txtName.Text + "');</script>", false);
   如果控件在updatepanel里 而且需要脚本控制 跳转加弹框的时候
                  ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "warning", "window.alert('您需要跳转');window.location.replace('DoTest.aspx');", true);
3可以在前台放一个<asp:Label runat="server" ID="lblShowScript" Text=""  ></asp:Label>  然后在后置代码类中可以写
  lblShowScript.Text="<script>alert('你要跳转?');</script>"; 此时 需要注意的是 我们有必要在此后置代码类中的Load事件里写上
lblShowScript.Text=""; 还原取消脚本
4 另外在服务器控件 按钮的前台属性中 还有onClientClick事件指的就是脚本的onclick事件


相关文档:

ASP.Net生成验证码

using System;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
public partial class images_code : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string chkCode = string.Empty;
//颜色列表,用于验证码、噪线、噪点
Color[] col ......

asp.net(C#)字符串加密

asp.net(C#)字符串加密
2010-03-12 09:59
using System;   
using System.Collections.Generic;   
using System.Text;   
using System.Security.Cryptography;//Cryptography密码术   
namespace DAL   
{   
......

ASP.NET中Cookie的操作

在学习过程中需要用到Cookie文件,在网上找了些相关的知识,学习了一部分,现记录如下:
(1)
HttpCookie myHttpCookie = new HttpCookie("MyWebSite");
DateTime myDateTime = System.DateTime.Now;
TimeSpan myTimeSpan = new TimeSpan();
if (rbHour.Checked == true)
{
    myTimeSpan = new Ti ......

ASP.NET常见错误及解决方法

在ASP.NET出现错误时,应该先检查ASP.NET环境是否正确搭建,比如以下几个方面:
1、是否安装相应版本的.NET Framework程序,并打好了补丁。
2、IIS是否安装运行正常,站点路径及ASP.NET版本是否配置正确。
3、在IIS WEB服务扩展中,是否允许了ASP.NET扩展。
4、是否有安全防护软件禁止向Windows和Temp文件夹写入文 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号