给自定义控件(Web Control)添加事件的几种方法。前两种方法可以不实现IPostBackEventHandler

vue2实现海康威视根据海康插件进行监控实时预览和回放功能,全套代码,开箱即用。 这是一篇基于vue2的海康视频实时预览和视频回放功能实现的步骤代码。 阅读详情

    写自定义控件已经好久了,也有几个用得时间比较长的,但是对于“事件”一直是比较模糊,没有很详细的理解。
    
    最近升级分页控件,由于原来使用的是VB.net(在VB.net里面添加一个事件是比较容易的),现在想改用C#,而原来的方法又写得比较笨拙,想换一个更简洁一点的方法,所以不得不重新认识一下事件。看了几遍《道不远人深入解析asp.net2.0控件开发》居然没有看懂,可能是自己太笨了吧。又找到了 自定义分页控件开发 看了几遍,还是比较迷糊,最后把《自定义分页控件开发》 里提供的代码down下来看了一下,终于有点明白了。

    先举一个简单的例子吧,我们建立一个复合控件,在CreateChildControls()里面添加两个控件,一个是Label,一个是LinkButton。我们的目的是要给自定义控件加一个事件,以便可以控制Label的Text属性。

     1、内部事件。
    这个好像是我起的名称,就是只在自定义控件的内部相应的事件,使用控件的页面不用相应相关的事件。具体一点就是要在自定义控件内部,在单击LinkButton的时候修改Label的值。   
public   class  EventTest : WebControl, INamingContainer  
    
{
protected override void CreateChildControls()
        
{
            Label lbl 
= new Label();
            lbl.ID 
= "lbl";
            
this.Controls.Add(lbl);
            
this.Controls.Add(new LiteralControl("<BR>"));
            LinkButton btn 
= new LinkButton();
            btn.ID 
= "btn";
            btn.Text 
= "复合控件的事件测试";
            
this.Controls.Add(btn);
 }

}



    编写好这段代码,然后把控件拖拽到页面里面里进行测试,运行后点击LinkButton,我们可以看到页面已经提交了,但是什么变化也没有,恩,我们还没有些事件呢。现在我们就给LinkButton加一个Click的事件。

protected   override   void  CreateChildControls()
        
{
            Label lbl 
= new Label();
            lbl.ID 
= "lbl"; 

            
this.Controls.Add(lbl);
            
this.Controls.Add(new LiteralControl("<BR>"));

            LinkButton btn 
= new LinkButton();
            btn.ID 
= "btn";
            btn.Text 
= "复合控件的事件测试";
            
this.Controls.Add(btn);

            
//给按钮添加内部事件            
            btn.Click += new EventHandler(btn_Click);
}


 
void  btn_Click( object  sender, EventArgs e)
        
{
            Label lbl 
= (Label)this.FindControl("lbl");
            lbl.Text 
+= "控件内部的事件,hi";
        }


    再次运行网页,单击,我们看到了想要的效果。

    怎么样简单吧,但是这种方法很不灵活,如果调用控件的网页也想相应事件怎么办呢?

     2、外部事件。
    这回我们要让自定义控件的外部也能相应事件。这个理论上我们要使用委托,也就是delegate,但是系统已经为我们定义好了一个( EventHandler),我们先用现成的。

    这样我们就给自定义控件定义了一个事件,重新编译,我们可以在控件的属性里面看到这个事件。(如果您没有看到,说明没有刷新,可能需要把IDE关闭,再次打开)。
 
public   event  EventHandler myClick
        
{
            add 
{
                Events.AddHandler(
this, value);
            }

            remove 
{
                Events.RemoveHandler(
this, value);
            }

        }


    我们可以添加外部的响应事件了,双击,我们加上几行代码。
在使用控件的网页里填写的代码  
protected   void  EventTest1_myClick( object  sender, EventArgs e)
        
{
            Label lbl 
= (Label)EventTest1.FindControl("lbl");
            lbl.Text 
+= "外部的事件,Hello" ;

        }



    运行,奇怪还是原来的样子,外部事件并没有相应,不是加了一个事件吗?外面的事件怎么没有被调用呢?这是因为,事件先触发自定义控件内部的事件,然后再由控件内部发出“命令”,调用外部的事件,那么我们怎样才能发出这个命令呢?我们需要要添加这个函数。这个也是最让我费解的地方,可能是对委托不是很了解的原因吧。
 

protected   void  TestClick( object  sender,EventArgs e)
        
{
            EventHandler hd 
= (EventHandler)base.Events[this];
            
if (hd != null)
            
{
                hd(sender, e);
            }

        }


    在修改一下  btn_Click() 就可以了。

void  btn_Click( object  sender, EventArgs e)
        
{
            Label lbl 
= (Label)this.FindControl("lbl");
            lbl.Text 
+= "控件内部的事件,hi";

            
//调用外部事件
            TestClick(sender, e);
        }

    再次运行,OK。

     (实现了内部和外部的事件相应,但是这时候我们还没有实现传说中的接口,这是为什么呢?)

    3、“借用”事件,没有成功。

    我们再给自定义控件加上几个<a>标签,让<a>也可以提交表单(就是触发事件),填写如下代码。
 
protected   override   void  CreateChildControls()
        
{
//省略。。。
this.Controls.Add(new LiteralControl("<BR><a id=/"aa/" href=/"javascript:__doPostBack('EventTest1$btn','')/">aa</a>"));
}


    运行OK。然后我们修改一下:__doPostBack的第二个参数,
 
< a id = / " aa/ "  href = / " javascript:__doPostBack('EventTest1$btn','1')/ " > aa </ a > " )


    奇怪,再次运行的时候出现了异常,看来不让这么做呀。

    依赖别人是不行了,必须要实现自定义控件自己的事件了。我们请来 IPostBackEventHandler 帮忙。同时<a>的href修改成
 
this .Controls.Add( new  LiteralControl( " <BR><a id=/ " a1/ "  href=/ " javascript:__doPostBack( ' "+ this.ClientID  +" ' , ' 1 ' )/ " >[1]</a> " ));
            
this .Controls.Add( new  LiteralControl( " &nbsp;<a id=/ " a2/ "  href=/ " javascript:__doPostBack( ' " + this.ClientID + " ' , ' 2 ' )/ " >[2]</a> " ));
            
this .Controls.Add( new  LiteralControl( " &nbsp;<a id=/ " a3/ "  href=/ " javascript:__doPostBack( ' " + this.ClientID + " ' , ' 3 ' )/ " >[3]</a> " ));
            
this .Controls.Add( new  LiteralControl( " &nbsp;<a id=/ " a4/ "  href=/ " javascript:__doPostBack( ' " + this.ClientID + " ' , ' 4 ' )/ " >[4]</a> " ));

在实现 RaisePostBackEvent 函数 
 
public   void  RaisePostBackEvent( string  Index)
        
{
            Label lbl 
= (Label)this.FindControl("lbl");
            lbl.Text 
+= "自己的事件:" + Index;
        }


    再次运行,OK。同时我们也得到了<a>传递过来的数字(页号)。

    还有一个 IPostBackDataHandler接口,由于暂时没不需要,所以没有研究,等用到的时候在研究。
----------------------------------------------------------------------

var  theForm  =  document.forms[ ' form1 ' ];
if  ( ! theForm)  {
    theForm 
= document.form1;
}

function  __doPostBack(eventTarget, eventArgument)  {
    
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value 
= eventTarget;
        theForm.__EVENTARGUMENT.value 
= eventArgument;
        theForm.submit();
    }

}


    如果您打开IE的“查看源文件”,会看到这个js函数,这是怎么来的呢?这个是button的事件带来的,虽然后面的代码并不需要button了,但是我比较懒,不想自己输出这个js函数,所以还是保留了button的事件。

    
    好像还是说的不太清楚。自定义控件的事件已经整理清楚了,我可以修改分页控件里的代码了,原来写的比较混乱。分页控件的下一个版本(v2.0.0.3)将增加两个事件,这样就可以向吴旗娃的分页控件那样灵活使用了。

附完整代码:

namespace  JYK.Controls.Page
{
    [DefaultProperty(
"Text")]
    [ToolboxData(
"<{0}:EventTest runat=server></{0}:EventTest>")]
    
public class EventTest : WebControl , INamingContainer,IPostBackEventHandler  
    
{
        
public event EventHandler myClick
        
{
            add
            
{
                Events.AddHandler(
this, value);
            }

            remove
            
{
                Events.RemoveHandler(
this, value);
            }

        }


        
protected void TestClick(object sender,EventArgs e)
        
{
            EventHandler hd 
= (EventHandler)base.Events[this];
            
if (hd != null)
            
{
                hd(sender, e);
            }

        }


        
public void RaisePostBackEvent(string Index)
        
{
            Label lbl 
= (Label)this.FindControl("lbl");
            lbl.Text 
+= "自己的事件:" + Index;
        }


        
protected override void CreateChildControls()
        
{
            Label lbl 
= new Label();
            lbl.ID 
= "lbl";

            
this.Controls.Add(lbl);
            
this.Controls.Add(new LiteralControl("<BR>"));

            LinkButton btn 
= new LinkButton();
            btn.ID 
= "btn";
            btn.Text 
= "复合控件的事件测试";
            
this.Controls.Add(btn);

            
//给按钮添加内部事件

            btn.Click 
+= new EventHandler(btn_Click);

          
this.Controls.Add(new LiteralControl("<BR><a id=/"aa/" href=/"javascript:__doPostBack('EventTest1$btn','')/">aa</a>"));

            
this.Controls.Add(new LiteralControl("<BR><a id=/"a1/" href=/"javascript:__doPostBack('"+ this.ClientID  +"','1')/">[1]</a>"));
            
this.Controls.Add(new LiteralControl("&nbsp;<a id=/"a2/" href=/"javascript:__doPostBack('" + this.ClientID + "','2')/">[2]</a>"));
            
this.Controls.Add(new LiteralControl("&nbsp;<a id=/"a3/" href=/"javascript:__doPostBack('" + this.ClientID + "','3')/">[3]</a>"));
            
this.Controls.Add(new LiteralControl("&nbsp;<a id=/"a4/" href=/"javascript:__doPostBack('" + this.ClientID + "','4')/">[4]</a>"));

        }


        
/// 控件内部的事件,由现有的控件的事件触发
         void btn_Click(object sender, EventArgs e)
        
{
            Label lbl 
= (Label)this.FindControl("lbl");
            lbl.Text 
+= "控件内部的事件,hi";

            
//调用外部事件
            TestClick(sender, e);
        }


        
protected override void Render(HtmlTextWriter output)
        
{
            
if ((base.Site != null) && base.Site.DesignMode)
            
{
                output.Write(
"<div style='TEXT-ALIGN: center;width:100%'>事件测试</div>");
            }

            
else
            
{
                
//Page_Click();
                
//output.Write("<div id='" + this.ClientID + "Page' style='TEXT-ALIGN: center;width:90%'>");
                base.Render(output);
                
//output.Write("</div>");
            }

        }

    }

}




《Leaflet 进阶知识点》- Leaflet.draw 交互绘制 一、安装 使用插件Leaflet.draw(GitHub地址、install) npm i leaflet-draw 二、 Vue 中引入 <script> 中引入 js import 'leaflet-draw' <style> 中引入 css @import '~leaflet-draw/dist/leaflet.draw.css' 三、初始化 //初始化绘制控件 this.drawControl = new L.Control.Draw({ .. 阅读详情

相关推荐

webcontrol

webcontrol,学习的内容,自用,勿下

vue项目中海康插件的使用

官方文档 :https://open.hikvision.com/docs/3784e07072ee4f09a573d61f20782267 插件版本:视频WEB插件 V1.5.1(见附件)(另附H5视频播放器开发包 V1.0.0,可用于移动端开发) 针对于web端的调用方法: 直接调用海康插件,需传参数 cameraIndexCode(监控点编号)。 调用海康接口,需传参数 url(监控点预览取流),需注意传输协议(rtsp,hls等)及延时情况。 以下为第一种方法(通过监控点编号cameraIn

iSmilee的博客 6531

yakit 验证码识别 进行webfuzzer

在渗透测试的过程中,我们可能需要对管理员密码进行枚举,或者密码喷洒的时候,遇到验证码就很烦。有没有自动化识别验证码的办法呢?有的,兄弟,有的。验证码的识别率很低,captcha-killer-modified对算术验证码识别正确率非常低,还会识别成乱七八糟的结果,这就非常麻烦。因为你不知道到底是验证码不对,还是密码不对。这是 ddddocr 识别率的问题,如果师傅们找到准确度更高的工具,完全可以替换上去。

Arkmornings的博客 1680

海康视频WEB插件 V1.5.2 开发总结

海康视频插件v.1.5.2开发教程总结,vue版本开箱即用组件分享

前端(全栈)、AI Agent开发技术分享 1万+

深入解析ffmpeg编码错误:avcodec_send_frame()返回-22的排查与修复

本文深入解析FFmpeg编码中avcodec_send_frame()返回-22(AVERROR(EINVAL))错误的根本原因与系统排查方法。核心问题通常在于编码器未正确打开或上下文传递错误。文章提供了从检查编码器查找、确认avcodec_open2()调用,到验证上下文传递的完整修复指南,并附有可运行的代码示例,帮助开发者快速定位并解决这一常见编码障碍。

weixin_28049429的博客 395

南京工业大学高性能计算平台基础使用指南

高性能计算平台基础使用指南前言什么高性能计算南京工业大学高性能计算平台如何登录如何进行文件传输进行任务提交(本文以提交MATLAB任务为例)环境变量的配置(推荐)使用Environment Modules进行环境变量管理Modules 指令自定义MODULEFILE常见软件任务脚本 前言 第一次接触使用学校的高性能平台是在今年上半年进行毕业设计的时候,当时有大量的数据需要在Matab中进行模型运算,便向学校申请了账号,使用了HPC平台。计算速度确实比个人电脑快了太多太多。 近期,有很多初次想使用高性能计算

weixin_45710019的博客 6883

给自定义控件(Web Control)添加事件的几种方法。前两种方法可以不实现IPostBackEventHandler...

写自定义控件已经好久了,也有几个用得时间比较长的,但是对于“事件”一直是比较模糊,没有很详细的理解。 最近升级分页控件,由于原来使用的是VB.net(在VB.net里面添加一个事件是比较容易的),现在想改用C#,而原来的方法又写得比较笨拙,想换一个更简洁一点的方法,所以不得不重新认识一下事件。看了几遍《道不远人深入解析asp.net2.0控件开发》居然没有看懂,可...

weixin_30569001的博客 97

计算机视觉入门:从像素到理解的旅程

计算机视觉入门:从像素到理解的旅程,计算机视觉是人工智能领域的核心方向之一,旨在让计算机具备理解和解释视觉信息的能力。本文以系统化的知识框架,结合 Python 代码与经典案例,带您从像素级操作逐步掌握计算机视觉核心技术。涵盖图像处理、特征工程、传统机器学习到深度学习模型,助您构建从基础到进阶的完整能力体系。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 18万+

给自定义控件(Web Control)添加事件的几种方法

给自定义控件(Web Control)添加事件的几种方法。前两种方法可以不实现IPostBackEventHandler     写自定义控件已经好久了,也有几个用得时间比较长的,但是对于“事件”一直是比较模糊,没有很详细的理解。          最近升级分页控件,由于原来使用的是VB.net(在VB.net里面添加一个事件是比较容易的),现在想改用C#,而原来的方法又写得比较笨拙,想

zlei2013141的专栏 1160

世界模型(World Models)进展全景调研(截至 2025-08)

A5) 2019-07(待核验) | C-SWM:Contrastive Structured World Models(Kipf et al.)A6) 2019-07(待核验) | SLAC:Stochastic Latent Actor-Critic(Lee et al.)A3) 2015-12(背景注记,待核验) | Embed to Control(E2C,Watter et al.)Nature 2020)Repro/Code:werner-duvaud/muzero-general(社区)

u013250861的博客 491

AI产品经理面试宝典第94天:RAG知识库构建与预处理策略面试指南

本文深入解析RAG知识库构建的核心挑战与预处理策略,涵盖文档格式转换、问答对生成及自动化测试全流程,为AI产品经理提供面试必备的实战方法论与避坑指南,助你精准应对技术深度类问题。

打造全国最全的AI Agent开发知识领域的博客 315

[Joe 原创]Web Control 开发系列(三) 解析IPostBackEventHandler和WebForm的事件机制

WebForm最大的魅力大概就是它自己的一套事件处理机制了,要做一个好的Control,必须深入理解这套机制,只有这样才可以让我们的Control有一整套Professional的Event,而IPostBackDataHandler和IPostBackEventHandler是实现事件机制的核心接口,在我的上一篇文章(Web Control 开发系列(二) 深入解析Pag...

diaogeng5745的博客 283

【100%通过率】2023华为od机试C卷【电脑病毒感染】Java&Go 实现

一个局域网内有很多台电脑,分别标注为 0 ~ N-1 的数字。相连接的电脑距离不一样,所以感染时间不一样,感染时间用t 表示。其中网络内一台电脑被病毒感染,求其感染网络内所有的电脑最少需要多长时间。如果最后有电脑不会感染,则返回-1.

MISAYAONE的博客 2869

自定义控件

asp.net控件继承自Control.UniqueID,ClientID属性. 实现接口: 1、数据回发接口。IPostBackDataHandler 两个方法: LoadPostData(PostDatakey key,PostBackDataCollention pos){  //获取属性的上次请求的值,间接从视图状态获得。   //给属性设置

十年一剑 515

2025华为od面试手撕代码【求字符串表达式结果】

2025华为od面试手撕代码【求字符串表达式结果】

MISAYAONE的博客 1363

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

自定义控件学习

 http://www.cnblogs.com/Clingingboy/archive/2006/09/17/506741.html 这个地方写的自定义控件教程不错!!Control类这是在开发自定义 ASP.NET 服务器控件时作为派生源的主要类。Control 没有任何针对用户界面 (UI) 的功能。如果创作没有 UI 的控件或者组合其他呈现它们自己的 UI 的控件,则从 Cont

swort_177的专栏 1294

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Web Control 开发系列(三) 解析IPostBackEventHandler和WebForm的事件机制

WebForm最大的魅力大概就是它自己的一套事件处理机制了,要做一个好的Control,必须深入理解这套机制,只有这样才可以让我们的Control有一整套Professional的Event,而IPostBackDataHandler和IPostBackEventHandler是实现事件机制的核心接口,在我的上一篇文章(Web Control 开发系列(二) 深入解析Page的PostBack过程...

weixin_34314962的博客 91

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

自定义控件-WebControl示例

using System;using System.Web.UI;using System.Text;namespace Goodspeed.Web{    /**////     /// Summary description for WebTimer    ///     public class WebTimer:Control, IPostBackEventHandler    {    

好文共赏 991

开发自定义控件

ASP.NET 服务器控件是直接或间接从 System.Web.UI.Control 派生的类。下面两个类是 ASP.NET 服务器控件的基类。 System.Web.UI.Control  Control 类定义了所有 ASP.NET 服务器控件共有的属性、方法和事件。其中包括控制控件执行生命周期的方法和事件,以及 ID、UniqueID、Parent、ViewState 和

yingyuelong的专栏 503

Asp.net WebControls基本概念

定义 WebControls可以通过拖放放置到asp.net页面上,支持设计时设置属性,封装一些好的WebControls可以极大的提高代码效率和代码质量。 几个概念 Web控件库项目 创建WebControls在vs中可以建立Web控件库项目,改项目下的类文件默认都继承自System.Web.UI.WebContro...

dieqibian1696的博客 515

WEBTIMER控件研究的心得:WebTimer的启示

ASP.NET的组件有两种,一种是继承自Control或者Webcontrol的CONTROL类组件,这类组件当你把它拖入到页面上时,它显示在页面上,另一种继承自Component类,这种不会显示在页面布局上,而是显示在COMPONENT TRAY上,这种,你可以叫它不可视组件,比如Sqlconnection组件要实现一个CONTROL类的控件,只要有下面的核心代码就行了 usi...

dianmeilan7150的博客 114

GetPostBackEventReference加RaisePostBackEvent实现自定义控件中回调传参

RaisePostBackEvent(string eventArgument) 说明:回调方法 参数:eventArgument,返回客户端回调参数值 Page.ClientScript.GetPostBackEventReference(control,string) 说明:客户端指定页面control控件中使用string字符串,以便回调回服务器 参数:control,实现Po...

weixin_30362801的博客 202

Asp.net自定义控件:概念

以下的内容是本人从微软的网站上摘录下来的 ASP.NET 服务器控件是直接或间接从 System.Web.UI.Control 派生的类,下面两个类是 ASP.NET 服务器控件的基类 ·System.Web.UI.Control Control 类定义了所有 ASP.NET 服务器控件共有的属性、方法和事件。其中包括控制控件执行生命周期的方法和事件,以及 ID、UniqueID、Par...

weixin_30757793的博客 87
上一篇: 【开源】QuickPager ASP.NET2.0分页控件 v2.0.0.2版本。
下一篇: 搬家了,jyk.cnblogs.com/
自然框架
博客等级 码龄24年 343粉丝 293原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值