代码碎片(用户控件使用客户端脚本)
2007-09-23 11:57
211 查看
用户控件HTML
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<%...@ Control Language="c#" AutoEventWireup="false" Codebehind="WebUserControl1.ascx.cs" Inherits="WebApplication4.WebUserControl1" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script language="javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<!--
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function <%= TextBox1.ClientID.Replace("_","")%>()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.all.<%= TextBox1.ClientID%>.value = "kent";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
//-->
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
用户控件后台代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace WebApplication4
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// WebUserControl1 的摘要说明。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public class WebUserControl1 : System.Web.UI.UserControl
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Page_Load(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 在此处放置用户代码以初始化页面
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.TextBox1.Attributes.Add("onmouseover",this.TextBox1.ClientID.Replace("_","")+"()");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
override protected void OnInit(EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
base.OnInit(e);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 设计器支持所需的方法 - 不要使用代码编辑器
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 修改此方法的内容。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Load += new System.EventHandler(this.Page_Load);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<%...@ Control Language="c#" AutoEventWireup="false" Codebehind="WebUserControl1.ascx.cs" Inherits="WebApplication4.WebUserControl1" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script language="javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<!--
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function <%= TextBox1.ClientID.Replace("_","")%>()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
document.all.<%= TextBox1.ClientID%>.value = "kent";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
//-->
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
用户控件后台代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace WebApplication4
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// WebUserControl1 的摘要说明。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public class WebUserControl1 : System.Web.UI.UserControl
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Page_Load(object sender, System.EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 在此处放置用户代码以初始化页面
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.TextBox1.Attributes.Add("onmouseover",this.TextBox1.ClientID.Replace("_","")+"()");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
override protected void OnInit(EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
base.OnInit(e);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 设计器支持所需的方法 - 不要使用代码编辑器
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 修改此方法的内容。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.Load += new System.EventHandler(this.Page_Load);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- 用户控件中使用客户端脚本的控件名称问题 (转)
- 用户控件中使用客户端脚本的控件名称问题
- 用户控件中使用客户端脚本的控件名称问题
- .net 用户控件ascx.cs注册js脚本代码无效果
- 判断用户使用的浏览器是否对系统合适的脚本代码
- 演示事件(Event)怎样使用以及怎样为用户控件添加一个事件(示例代码下载)
- 演示事件(Event)怎样使用以及怎样为用户控件添加一个事件(示例代码下载)
- 请问web用户控件中如何使用javascript脚本??
- 演示事件(Event)怎样使用以及怎样为用户控件添加一个事件(示例代码下载)
- 使用asp.net开发客户端脚本代码(Chinese ,from csdn)
- 用户控件的后台代码关联使用CodeBehind还是CodeFile
- 服务器端控件使用客户端脚本
- 演示事件(Event)怎样使用以及怎样为用户控件添加一个事件(示例代码下载)
- 服务器端控件使用客户端脚本
- 服务器控件使用客户端脚本
- 演示事件(Event)怎样使用以及怎样为用户控件添加一个事件(示例代码下载)
- 让服务器控件的事件同时执行客户端脚本和服务器端代码-转载
- 绝对酷,如何解决asp.net中javascript脚本的问题(使用服务器控件执行客户端脚本)
- [原创]用户控件中使用Js,如何在客户端引用用户控件中某个控件的ID
- 演示事件(Event)怎样使用以及怎样为用户控件添加一个事件(示例代码下载)