易截截图软件、单文件、免安装、纯绿色、仅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事件


相关文档:

SharpDevelop开发Asp.net

设置SharpDevelop,使其能编写和运行Asp.net。
在看下文的时候,请确定您的系统装上了IIS,FontPage扩展,装了.Net框架。好现在开始我的讲述。
     如果您装的.Net框架是1.1版的,请生成以下BAT文件。
     文件:Asp.Net_1.1_Setup.bat
     c:
  ......

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 Session 详解

Session模型简介
Session是什么呢?简单来说就是服务器给客户端的一个编号。当一台WWW服务器运行时,可能有若干个用户浏览正在运正在这台服务器上的网站。当每个用户首次和这台WWW服务器建立连接时,他就和这个服务器建立了一个Session,同时服务器会自动为其分配一个SessionID,用以标识这个用户的唯一身份。这个SessionI ......

简单的Javascript Cookie操作

<mce:script type="text/javascript"><!--

function SetCookie(name,value,expire) {
var exp = new Date();
exp.setTime(exp.getTime() + expire);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
} ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号